mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-09-20 20:39:55 +00:00
feat(nginx): 更新SSL证书路径配置
fix(deploy): 移除对main分支的拉取尝试 feat(task): 添加节点处理器模块和示例代码 refactor(scheduler): 改进任务执行包装器支持完整Python语法 style(monitor): 允许资源文件URL为相对路径 chore(deps): 降级requests版本到2.32.3 refactor(frontend): 更新节点任务示例代码 refactor(docker): 优化docker-compose配置和健康检查 refactor(resource): 加强文件路径安全检查和URL处理
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
"""
|
||||
节点执行处理器模块
|
||||
|
||||
提供各种封装好的方法供节点执行函数调用
|
||||
|
||||
使用方法:
|
||||
在节点执行函数中,所有工具函数已经自动加载到全局命名空间,
|
||||
可以直接使用,无需导入。
|
||||
|
||||
例如:
|
||||
def handler(*args, **kwargs):
|
||||
log_info("任务开始")
|
||||
result = http_get("https://api.example.com")
|
||||
log_info(f"请求结果: {result}")
|
||||
return result
|
||||
"""
|
||||
|
||||
# 这个模块的主要作用是提供文档说明
|
||||
# 实际的功能函数在 context.py 中定义,并通过 NodeExecutionContext 注入到执行环境
|
||||
|
||||
__all__ = []
|
||||
@@ -0,0 +1,42 @@
|
||||
"""
|
||||
示例处理器模块
|
||||
|
||||
提供简单的示例方法供节点执行函数调用
|
||||
"""
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
def demo_handler(*args, **kwargs) -> dict:
|
||||
"""示例处理器"""
|
||||
return {
|
||||
"message": "Hello from demo_handler!",
|
||||
"args": args,
|
||||
"kwargs": kwargs,
|
||||
"time": datetime.now().isoformat(),
|
||||
}
|
||||
|
||||
|
||||
def process_data(data: list, operation: str = "sum") -> dict:
|
||||
"""
|
||||
简单数据处理
|
||||
|
||||
operation: sum, avg, max, min, count
|
||||
"""
|
||||
if not data:
|
||||
return {"error": "数据为空"}
|
||||
|
||||
if operation == "sum":
|
||||
result = sum(data)
|
||||
elif operation == "avg":
|
||||
result = sum(data) / len(data)
|
||||
elif operation == "max":
|
||||
result = max(data)
|
||||
elif operation == "min":
|
||||
result = min(data)
|
||||
elif operation == "count":
|
||||
result = len(data)
|
||||
else:
|
||||
return {"error": f"不支持的操作: {operation}"}
|
||||
|
||||
return {"operation": operation, "result": result}
|
||||
Reference in New Issue
Block a user