# event schema in functions-framework functions-framework 的 async 部分是基于 dapr 完成的,而现在 dapr 的事件格式分为 bindingEvent 和 topicEvent 两种,且针对不同的 component,不能对事件的处理进行标准的处理。 现在我们已经为 functions-framework 引入了插件机制,开发者可以定制函数执行前后的处理流程。为了能够降低这部分工作的开发成本,同时也是为了让 functions-framework 完成 workflow 机制的预接入,我们需要按照 serverlessworkflow 和 cloudevents 的 specification,重新约定 functions-framework 中的事件传递格式。 按照 CloudEvents 的规范,我们按以下内容约定各字段的含义: - id,string,事件 ID,使用 uuid 格式 - 示例:"123e4567-e89b-12d3-a456-426614174000" - 针对 bindingEvent,直接生成 uuid;针对 topicEvent,则根据 topicEvent id 生成 uuid - source,URI-reference,事件源标识,使用函数的 namespace / name - 示例:"default/function-a" - specversion,string,cloudevents spec 版本号 - type,string,事件类型 - 示例:"io.openfunction.function.default-function-a" - datacontenttype,string,数据内容类型 - 示例:"application/json" - dataschema,URI,未定 - subject,string,"cluster/namespace/name" - 示例:"cluster-a/default/function-a" - time,Timestamp,时间戳 - data,事件内容 - userData,用于记录用户数据 - metadata,用于记录元数据信息 - 示例: ```go type eventInner struct { Metadata map[string]string `json:"metadata,omitempty"` UserData interface{} `json:"userData,omitempty"` } ``` 完整示例: ```json { "id": "123e4567-e89b-12d3-a456-426614174000", "source": "default/function-a", "specversion": "v1", "type": "io.openfunction.function.default-function-a", "datacontenttype": "application/json", "subject": "cluster-a/default/function-a", "time": "2019-11-18T15:13:39.4589254Z", "data": { "metadata": { "key1": "value1", "key2": "value2" }, "userData": "****" } } ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up