Updated on 2023-11-21 GMT+08:00

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:

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.

  1. Log in to the FunctionGraph console. In the navigation pane, choose Functions > Function List.
  2. Click the function to be configured to go to the function details page.
  3. Choose Configuration > Permissions, and change the agency to serverless-trust created in Configuring Agency Permissions.
  4. Click Save.

Creating a DIS Trigger

  1. Return to the FunctionGraph console. In the navigation pane, choose Functions > Function List.
  2. Click the function to be configured to go to the function details page.
  3. Choose Configuration > Triggers and click Create Trigger.
  4. Set the following parameters:

    • Trigger Type: Select Data Ingestion Service (DIS).
    • Stream Name: Select a DIS stream, for example, dis-function.
    • Max. Fetch Bytes: 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 1 KB to 4 MB.
    • 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.
    • 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.

  5. Click OK.

Configuring a DIS Event to Trigger the Function

  1. Return to the FunctionGraph console. In the navigation pane, choose Functions > Function List.
  2. Click the function to be configured to go to the function details page.
  3. On the function details page, select a version.
  4. On the Code tab page, click Test. The Configure Test Event dialog box is displayed.
  5. Set the parameters described in Table 1 and click Save.

    Table 1 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.

  6. Click Test. The function test result is displayed.