Triggers in Yandex API Gateway. Overview
A trigger is a condition, upon meeting which an automatic message is sent to WebSocket connections connected to the API gateway at the path specified by the user. The API gateway itself is not called.
Triggers allow you to automate your work with other Yandex Cloud services, such as Yandex Object Storage, Yandex Message Queue, and Yandex Container Registry.
Note
The trigger is initiated within 5 minutes of being created.
The following types of triggers are available in Yandex API Gateway:
- Timer
- Trigger for Message Queue
- Trigger for Object Storage
- Trigger for Container Registry
- Trigger for Cloud Logging
- Trigger for Yandex IoT Core
- Trigger for budgets
- Trigger for Data Streams
- Email trigger
Each trigger type has its own conditions. For example, a trigger for Object Storage may fire when an object is created or updated. You can set some conditions in the service object settings, e.g., notification thresholds in the budget settings would act as trigger conditions for budgets.
Things to consider about trigger messages
Triggers send messages based on preset quotas and limits.
You need to consider the following points:
- The trigger reformats messages before sending them to WebSocket connections. Each trigger type uses a message format of its own. Read more about this in the relevant trigger description.
- If sending fails or the path specified in the trigger settings has no clients connected, the message gets lost and resending is not possible.
- The service account you are going to use to send messages to WebSocket connections must have the
functions.functionInvokerrole. Other roles required for the trigger to operate correctly depend on trigger type. Read more about this in the relevant trigger description.
Message batching
You can configure the following triggers to batch messages before sending them to WebSocket connections:
- Trigger for Message Queue
- Trigger for Cloud Logging
- Trigger for Object Storage
- Trigger for Container Registry
- Trigger for Yandex IoT Core
- Trigger for Data Streams
- Email trigger
This will allow sending messages as a batch rather than one by one. Specify the following in the trigger parameters:
- Waiting time, s: Message batching time. The number of messages cannot exceed the specified batch size.
- Batch size: Number of messages for batching.
For more information about message batching, see the guides for creating the relevant trigger.