Using a DIS Trigger
For details about the DIS event source, see Supported Event Sources.
Prerequisites
Before creating a trigger, ensure that you have prepared the following:
- You have created a function. For details, see Creating a Function from Scratch.
- You have created a DIS stream, for example, dis-function. For details, see Creating a DIS Stream.
Setting an Agency
Before creating a DIS trigger, set an agency to delegate FunctionGraph to access DIS. For details on how to create an agency, see Configuring Agency Permissions.
Since you did not specify an agency while creating the HelloWorld function, specify one first.
- Log in to the FunctionGraph console. In the navigation pane, choose Functions > Function List.
- Click the function to be configured to go to the function details page.
- Choose Configuration > Permissions, and change the agency to serverless-trust created in Configuring Agency Permissions.
- Click Save.
Creating a DIS Trigger
- Return to the FunctionGraph console. In the navigation pane, choose Functions > Function List.
- Click the function to be configured to go to the function details page.
- Choose Configuration > Triggers and click Create Trigger.
- Set the following parameters:
- Trigger Type: Select Data Ingestion Service (DIS).
- Stream Name: Select a DIS stream, for example, dis-function.
- Starting Position: Specify a position in the specified stream from which to start reading data.
- TRIM_HORIZON: Data is read from the earliest valid records that are stored in the partition.
- LATEST: Data is read just after the most recent record in the partition. This setting ensures that you always read the latest data.
- Data processing: By Byte and By Batch.
Table 1 Data Processing Data processing mode
Description
By Byte
Configure Max. Fetch Bytes which indicates the maximum volume of data that can be fetched in each request. Only the records smaller than this value will be fetched. The value ranges from 0 KB to 4 MB.
By Batch
Configure Batch Size which indicates the maximum number of data records pulled at a time. Only the records smaller than this value will be fetched. The value ranges from 1 to 10,000. The total number of data records pulled at the same time cannot exceed 4 MB.
By default, users do not have permission to use the By Batch mode. To use it, submit a service ticket to add a whitelist.
- Pull Period: Set a period for pulling data from the stream.
- Serial Data Processing: If this option is selected, FunctionGraph pulls data from the stream only after previous data is processed. If this option is not selected, FunctionGraph pulls data from the stream as long as the pull period ends.
After Serial Data Processing is disabled, you can configure the concurrency (1–80) to limit the number of concurrent asynchronous invocation requests from a DIS trigger. This prevents a single DIS trigger with mass traffic from occupying the concurrency quota and affecting other DIS triggers. (Currently available only in CN North-Beijing4)Figure 1 Disabling serial data processing
- Click OK.
Modifying a DIS Trigger
Some parameters of DIS triggers can be modified.
- Return to the FunctionGraph console. In the navigation pane, choose Functions > Function List.
- Click the function to be configured to go to the function details page.
- Choose Configuration > Triggers, and click Edit next to a DIS trigger.
- Modify Max. Fetch Bytes/Batch Size, Pull Period, and Serial Data Processing as required, and click OK.
Configuring a DIS Event to Trigger the Function
- Return to the FunctionGraph console. In the navigation pane, choose Functions > Function List.
- Click the function to be configured to go to the function details page.
- On the function details page, select a version.
- On the Code tab page, click Test. The Configure Test Event dialog box is displayed.
- Set the parameters described in Table 2 and click Save.
Table 2 Test event information Parameter
Description
Configure Test Event
You can choose to create a test event or edit an existing one.
Use the default option Create new test event.
Event Template
Select Data Ingestion Service (DIS) to use the built-in DIS event template.
Event Name
The event name can contain 1 to 25 characters and must start with a letter and end with a letter or digit. Only letters, digits, underscores (_), and hyphens (-) are allowed. For example, dis-123test.
Event data
The system automatically loads the built-in DIS event template, which is used in this example without modifications.
- Click Test. The function test result is displayed.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot