Supported Event Sources
This section describes the cloud services that can be configured as event sources for your FunctionGraph functions. After you preconfigure the event source mapping, these event sources automatically invoke the relevant function when detecting events.
SMN
Simple Message Notification (SMN) sends messages to email addresses, mobile phones, or HTTP/HTTPS URLs. If you create a function with an SMN trigger, messages published to a specified topic will be passed as a parameter (SMN example event) to invoke the function. Then, the function processes the event, for example, publishing messages to other SMN topics or sending them to other cloud services. For details, see Using an SMN Trigger.
APIG
API Gateway (APIG) is an API hosting service that helps enterprises to build, manage, and deploy APIs at any scale. With APIG, your function can be invoked through HTTPS by using a custom REST API and a specified backend. You can map each API operation (such as, GET and PUT) to a specific function. APIG invokes the relevant function when an HTTPS request (APIG example event) is sent to the API backend. For details, see Using an APIG Trigger.
Timer
You can schedule a timer (timer example event) to invoke your code based on a fixed rate of minutes, hours, or days or a cron expression. For details, see Using a Timer Trigger.
DMS for Kafka
DMS for Kafka is a message queuing service that provides Kafka premium instances. If you create a Kafka trigger for a function, when a message is sent to a Kafka instance topic, FunctionGraph will retrieve the message and trigger the function to perform other operations. For details, see Using a Kafka Trigger.
Cloud Eye
Cloud Eye is a multi-dimensional resource monitoring platform. FunctionGraph is interconnected with Cloud Eye to report metrics, allowing you to view function metrics and alarm messages through Cloud Eye. For more information about metrics, see Viewing Function Metrics.
DMS for RabbitMQ
When a DMS (for RabbitMQ) trigger is used, FunctionGraph periodically polls for new messages in a specific topic bound to the exchange of a RabbitMQ instance and passes the messages as input parameters to invoke functions.
Example Events
- SMN example event
{ "record": [ { "event_version": "1.0", "smn": { "topic_urn": "urn:smn:{region}:0162c0f220284698b77a3d264376343a:{function_name}", "timestamp": "2018-01-09T07:11:40Z", "message_attributes": null, "message": "this is smn message content", "type": "notification", "message_id": "a51671f77d4a479cacb09e2cd591a983", "subject": "this is smn message subject" }, "event_subscription_urn": "urn:fss:{region}:0162c0f220284698b77a3d264376343a:function:default:read-smn-message:latest", "event_source": "smn" } ], "functionname": "test", "requestId": "7c307f6a-cf68-4e65-8be0-4c77405a1b2c", "timestamp": "Wed Nov 15 2017 12:00:00 GMT+0800 (CST)" }
Table 1 Parameter description Parameter
Type
Example Value
Description
event_version
String
1.0
Event version
topic_urn
String
See the example.
ID of an SMN event
type
String
notification
Event type
RequestID
String
7c307f6a-cf68-4e65-8be0-4c77405a1b2c
Request ID. The ID of each request is unique.
message_id
String
a51671f77d4a479cacb09e2cd591a983
Message ID. The ID of each message is unique.
Message
String
this is smn message content
Message content
event_source
String
smn
Event source
event_subscription_urn
String
See the example.
Subscription ID
timestamp
String
Wed Nov 15 2017 12:00:00 GMT+0800 (CST)
Time when an event occurs
- APIG example event
{ "body": "{\"test\":\"body\"}", "requestContext": { "apiId": "bc1dcffd-aa35-474d-897c-d53425a4c08e", "requestId": "11cdcdcf33949dc6d722640a13091c77", "stage": "RELEASE" }, "queryStringParameters": { "responseType": "html" }, "httpMethod": "GET", "pathParameters": { "path":"value" }, "headers": { "accept-language": "en-US;q=0.3,en;q=0.2", "accept-encoding": "gzip, deflate, br", "x-forwarded-port": "443", "x-forwarded-for": "103.218.216.98", "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "upgrade-insecure-requests": "1", "host": "50eedf92-c9ad-4ac0-827e-d7c11415d4f1.apigw.region.cloud.com", "x-forwarded-proto": "https", "pragma": "no-cache", "cache-control": "no-cache", "x-real-ip": "103.218.216.98", "user-agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:57.0) Gecko/20100101 Firefox/57.0" }, "path": "/apig-event-template", "isBase64Encoded": true }
- When calling a function using APIG, isBase64Encoded is valued true by default, indicating that the request body transferred to FunctionGraph is encoded using Base64 and must be decoded for processing.
- The function must return characters strings by using the following structure.
{ "isBase64Encoded": true|false, "statusCode": httpStatusCode, "headers": {"headerName":"headerValue",...}, "body": "..." }
Table 2 Parameter description Parameter
Type
Example Value
Description
body
String
"{\"test\":\"body\"}"
Actual request in string format
requestContext
Map
See the example.
Request information, including the API gateway configuration, request ID, authentication information, and source
httpMethod
String
GET
HTTP method
queryStringParameters
Map
See the example.
Query strings configured in APIG and their actual values
pathParameters
Map
See the example.
Path parameters configured in APIG and their actual values
headers
Map
See the example.
Complete headers
path
String
/apig-event-template
Complete path
isBase64Encoded
Boolean
True
Default value: true
- Timer example event
{ "version": "v1.0", "time": "2018-06-01T08:30:00+08:00", "trigger_type": "TIMER", "trigger_name": "Timer_001", "user_event": "User Event" }
Table 3 Parameter description Parameter
Type
Example Value
Description
version
String
V1.0
Event version
time
String
2018-06-01T08:30:00+08:00
Time when an event occurs.
trigger_type
String
TIMER
Trigger type
trigger_name
String
Timer_001
Trigger name
user_event
String
User Event
Additional information of the trigger
- Kafka example event
{ "event_version": "v1.0", "event_time": 1576737962, "trigger_type": "KAFKA", "region": "{region}", "instance_id": "81335d56-b9fe-4679-ba95-7030949cc76b", "records": [ { "messages": [ "kafka message1", "kafka message2", "kafka message3", "kafka message4", "kafka message5" ], "topic_id": "topic-test" } ] }
Table 4 Parameter description Parameter
Type
Example Value
Description
event_version
String
v1.0
Event version
event_time
String
2018-01-09T07:50:50.028Z
Time when an event occurs
trigger_type
String
KAFKA
Event type
region
String
ap-southeast-3
Region where a Kafka instance resides
instance_id
String
81335d56-b9fe-4679-ba95-7030949cc76b
Kafka instance ID
messages
String
See the example.
Message content
topic_id
String
topic-test
Message ID
- RabbitMQ example event
{ "event_version": "v1.0", "event_time": 1576737962, "trigger_type": "RABBITMQ", "region": "{region}", "records": [ { "messages": [ "rabbitmq message1", "rabbitmq message2", "rabbitmq message3", "rabbitmq message4", "rabbitmq message5" ], "instance_id": "81335d56-b9fe-4679-ba95-7030949cc76b", "exchange": "exchange-test" } ] }
Table 5 Parameter description Parameter
Type
Example Value
Description
event_version
String
v1.0
Event version
Region
String
ap-southeast-3
Region where a RabbitMQ instance resides
instance_id
String
81335d56-b9fe-4679-ba95-7030949cc76b
RabbitMQ instance ID
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.