|
@@ -19,11 +19,12 @@ handlerFileName = 'spider_result_handler'
|
|
|
py_code_source_dir = os.environ.get('FAAS_CODE_DIR', 'F:/codes/python/clientSpider/')
|
|
|
|
|
|
py_code_handler_path_list = [py_code_source_dir + handlerFileName]
|
|
|
+# 安全考虑,只能调用该目录下的方法,而不是任意模块方法,且作为 faas 服务内部约定,外部服务不需要感知该模块/目录名;但其目录下子目录/模块不做限制
|
|
|
py_code_handler_module_prefix = handlerFileName + '.'
|
|
|
|
|
|
# --------------------------------------约定------------------------------------------------------
|
|
|
-support_function_name = 'support'
|
|
|
-default_function_name = 'handle'
|
|
|
+faas_function_name__support = 'support'
|
|
|
+faas_function_name__handle = 'handle'
|
|
|
|
|
|
const_key_function_id = "faas__function-id"
|
|
|
const_key_request_wrap = "faas__request_wrap"
|
|
@@ -46,6 +47,7 @@ const_key_trace_id = "faas__trace_id"
|
|
|
loaded_functions_cache = {}
|
|
|
|
|
|
|
|
|
+# todo 进程锁
|
|
|
def load_functions(force_reload_module):
|
|
|
"""
|
|
|
加载指定目录下的所有函数
|
|
@@ -73,6 +75,7 @@ def func_route(func_dic, func_name, args={}):
|
|
|
"""
|
|
|
函数路由: 根据函数名执行调用
|
|
|
"""
|
|
|
+ # fixme 判断是否存在
|
|
|
func = func_dic[func_name]
|
|
|
print(func)
|
|
|
|
|
@@ -95,8 +98,8 @@ def handle(pycode_file_name, req):
|
|
|
|
|
|
json_req = json.loads(req)
|
|
|
|
|
|
- support_func_name = py_code_handler_module_prefix + "%s-%s" % (pycode_file_name, support_function_name)
|
|
|
- pycode_function_id = py_code_handler_module_prefix + "%s-%s" % (pycode_file_name, default_function_name)
|
|
|
+ support_func_name = py_code_handler_module_prefix + "%s-%s" % (pycode_file_name, faas_function_name__support)
|
|
|
+ pycode_function_id = py_code_handler_module_prefix + "%s-%s" % (pycode_file_name, faas_function_name__handle)
|
|
|
|
|
|
global loaded_functions_cache
|
|
|
|