更新时间:2022-02-22 GMT+08:00
同步执行函数
URI
POST /v2/{project_id}/fgs/functions/{function_urn}/invocations
URI参数说明如表1所示。
Header:X-Cff-Log-Type,取值为:tail(返回函数执行后的4K日志),或者为空(不返回日志)。
请求消息
函数的event,json格式。
参数 | 类型 | 必选 | 说明 |
|---|---|---|---|
{自定义key} | Map<String,String> | 否 | 执行函数请求体,为json格式 |
响应消息
响应参数说明如表2所示。
参数 | 类型 | 说明 |
|---|---|---|
X-Cff-Function-Log | String | base64编码后的函数执行日志。 |
X-Cff-Invoke-Summary | JSON | 执行摘要。 |
Body | JSON | 函数执行结果。 |
X-Cff-Invoke-Summary示例如下:
{"duration":1.913,"billingDuration":100,"memorySize":128,"memoryUsed":41.51171875} 参数 | 说明 |
|---|---|
duration | 函数执行时长,单位毫秒(ms)。 |
billingDuration | 收费时长,单位毫秒(ms)。 |
memorySize | 配置内存,单位兆(MB)。 |
memoryUsed | 实际使用内存,单位兆(MB)。 |
示例
请求示例
POST /v2/7aad83af3e8d42e99ac194e8419e2c9b/fgs/functions/urn:fss:xxxxxxxxx:7aad83af3e8d42e99ac194e8419e2c9b:function:default:test:latest/invocations HTTP/1.1
{
"message":"Hello World"
} 响应示例
成功时的返回格式:
HTTP/1.1 200 OK
{"message": "hello world from FunctionStage"} 失败时的返回格式:
HTTP/1.1 404 Not Found
{"error_code":"FSS.0404","error_msg":"Not found the specified resource"} 状态码
状态码请参见状态码。
父主题:函数数据域接口


