Updated on 2024-03-29 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.
    • 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

  5. Click OK.

Modifying a DIS Trigger

Some parameters of DIS triggers can be modified.

  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 Edit next to a DIS trigger.
  4. 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

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

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