Trigger for Data Streams that invokes a Cloud Functions function
Trigger for Data Streams calls a Cloud Functions function when data is sent to a stream.
A trigger for Data Streams needs service accounts to manage a stream and invoke a function. You can use the same service account for both operations.
For more information about creating a trigger for Data Streams, see Creating a trigger for Data Streams that invokes Cloud Functions.
Message batching
Batching settings allow you to send multiple messages to a function at the same time. They set a top limit on the message batch size and accumulation time. For example, if the message batch size is 3, the function can receive batches of one to three messages.
Roles required for the proper operation of a trigger for Data Streams
- To create a trigger, you need a permission for the service account under which the trigger runs the operation. This permission comes with the iam.serviceAccounts.user and editor roles or higher.
- For the trigger to fire, service accounts need the following roles:
functions.functionInvokerfor the function the trigger invokes.yds.adminfor the stream that invokes the trigger when data is sent there.
Format of the message from the trigger for Data Streams
The trigger for Data Streams receives and sends messages in JSON
Once the trigger fires, it will send a message with the messages array to the function:
{
"messages":[
{
"key1":"value1"
},
{
"key2":"value2"
}
]
}