BaaS Functions 模块
⚠️ 待验证 - 此模块功能正在验证中
无服务器函数模块 - HTTP 函数执行和定时任务调度。
📦 模块信息
- 依赖: Node.js Functions Service
- 位置:
web/modules/custom/baas_functions/(Drupal) +docker/nodejs-services/baas-functions/(Node.js)
🏗️ 核心功能
HTTP 函数
- 自定义 HTTP 端点
- 函数代码动态加载
- 超时和内存限制
定时任务
- Cron 表达式支持
- 定时触发函数
- 任务执行日志
🔧 主要组件
Node.js Functions Service
函数执行服务 - docker/nodejs-services/baas-functions/
// HTTP 端点
POST http://YOUR_HOST:3001/functions/execute
// WebSocket 端点
ws://YOUR_HOST:4000FunctionService (Drupal)
函数管理服务 - src/Service/FunctionService.php
// 注册函数
public function registerFunction(string $name, string $code): bool
// 执行函数
public function executeFunction(string $name, array $params): array
// 删除函数
public function deleteFunction(string $name): bool📖 使用示例
创建函数
// 函数代码示例
exports.handler = async (event) => {
const { user_id } = event;
// 业务逻辑
return {
success: true,
data: { user_id }
};
};调用函数
curl -X POST http://YOUR_HOST:3001/functions/execute \
-H "Content-Type: application/json" \
-d '{
"function_name": "my_function",
"params": { "user_id": 123 }
}'🔌 服务配置
Docker Compose 配置:
baas-functions:
ports:
- "3001:3001" # HTTP
- "4000:4000" # WebSocket
environment:
- NODE_ENV=development
- PORT=3001
- ENABLE_REALTIME=true🔗 相关文档
- BaaS Functions Service - Node.js 运行时服务详解
- 详细文档正在完善中…
Last updated on