DataWorks allows you to use a custom extension to process extension point events to which you subscribe and send processing results to DataWorks by using the OpenAPI module. This topic describes how to develop a custom extension and the precautions that you must take during the procedure.

Prerequisites

The message subscription feature is enabled, a custom extension is registered, and the information that is required to develop the extension is obtained. For more information, see Preparations.

Develop a custom extension

When you develop code for a custom extension, take note of the following items:
  1. Subscribe to and parse the messages of extension point events.
  2. Obtain the snapshots of extension point events and process events based on the snapshots.
    • You can configure the messageId parameter in the API operation that you called to obtain the snapshots of extension point events.
      Note
      • You can call the UpdateIDEEventResult API operation for extension point events in DataStudio and the UpdateWorkbenchEventResult API operation for extension point events in Operation Center.
      • You can obtain the value of the messageId parameter by parsing event messages.
    • You can use parameters to improve effectiveness of code development and application. For example, you can use the built-in parameter extension.project.disabled of a custom extension to specify that the extension does not take effect for the specified workspaces. For more information about the built-in parameters that you can use to develop extension code, see Advanced feature: Configure extension parameters.
  3. Send processing results to DataWorks.
    You can call an API operation to configure the extension to return the processing results of extension point events to DataWorks.
    Note You can call the UpdateIDEEventResult API operation for extension point events in DataStudio and the UpdateWorkbenchEventResult API operation for extension point events in Operation Center.

Sample code used to develop a custom extension

After you understand the precautions that you must take during the extension development procedure, you can develop extension code based on your business requirements. The following topics also provide examples on extension registration, development, and application in typical scenarios.

Deploy a custom extension

After you develop and debug the code of a custom extension, you can deploy the extension to your on-premises machine or to an Alibaba Cloud Elastic Compute Service (ECS) instance as a service application. You can also develop a web page to allow users to view the processing process and status of each event, and a help documentation page to help users understand the business logic of the extension. You can add the page URLs and the parameters that you use in the code to the registration information of the extension in the To register your Extension program (Extension) dialog box. Deploy a custom extensionThe following table describes the parameters in the To register your Extension program (Extension) dialog box.
ParameterDescription
Extension nameThe name of the extension.
Extension point of processingThe type of the extension point event that you want the extension to check. For more information about supported extension point events, see Supported extension point events. You can configure this parameter based on your business requirements.
Note After you configure this parameter, the system automatically configures the Event and Applicable module parameters.
HeadThe person in charge of the extension. Users of the extension can contact the extension owner at the earliest opportunity when they encounter problems.
Test workspaceThe workspace that is used to test the extension.

To check whether the extension is effective, you do not need to deploy the extension because the test workspace supports an end-to-end test that allows you to check whether the extension works as expected.

In the test workspace, developers can trigger events to check whether DataWorks sends related messages to the extension by using EventBridge and whether the extension checks the events and sends the check results to DataWorks.

Extensions Details AddressThe URL of the extension details page.

After you develop and deploy the extension, you can develop a web page to display how the extension works. Set this parameter to the page URL so that users can visit this web page to better understand and use the extension. For example, users can visit the web page to check why a node is blocked by the extension.

Extension document addressThe URL of the extension documentation page.

After you develop and deploy the extension, you can develop a help documentation page. Set this parameter to the page URL so that users can know the business logic and properties of the extension.

Extensions parameter configurationThe extension parameters. To improve the extension development and application efficiency, you can enter both the built-in parameters for typical scenarios and custom parameters for future reference.

You can enter multiple parameters, each occupying a separate line and defined in the format of key=value. For more information about how to use these parameters, see Advanced feature: Configure extension parameters.

Extensions option configurationThe configuration item for the extension. The extension developer provides this parameter for users to implement custom process management in different workspaces based on their business requirements when the users register the extension. The extension developer must define the configuration item in JSON strings in the Register Extension dialog box. For example, the extension developer allows users to manage the length of an SQL statement based on this parameter. For more information about the JSON format, see Advanced feature: Define options for an extension.