Updated on 2026-01-08 GMT+08:00

Developing an Event Function

You can compile a function only via uploading a ZIP package with all required dependencies.

Preparation

Obtain the Cangjie demo project package from technical support.

Compiling and Packaging

Run the cjpm build command to generate a libxxxx.so file in the build directory. You need to compress the .so file into a .zip file, as shown in Figure 1.
Figure 1 Packaging the file into a .zip file

Creating a Function

  1. Log in to the FunctionGraph console and click Create Function in the upper right corner. The Create Function page is displayed.
  2. Select Create from scratch and set the following parameters:

    • Function Type: Select Event Function.
    • Region: Select a region.
    • Function Name: Enter a custom name.
    • Enterprise Project: Select an enterprise project as required.
    • Agency: Select an existing agency. For details about how to create an agency, see section "Creating an Agency" in the FunctionGraph User Guide.
    • Runtime: select Cangjie 1.0.

  3. Click Create Function.

Configuring Functions

  1. Return to the FunctionGraph console, choose Functions > Function List on the left, locate the created function, and click its name. The function details page is displayed.
  2. On the Code tab page, choose Upload > Local ZIP > Select File on the right to upload the prepared demo package. After the upload is successful, click OK.
  3. Choose Configuration > Basic Settings. Set the handler to the name of the .so file in Compiling and Packaging, for example, libuser_func_test_success.so, and click Save.

Testing Function Invocation

  1. On the function details page, choose Code > Configure Test Event. In the dialog box that is displayed, click Create new test event > Blank Template.

    The contents of the test cases are as follows:

    {
        "isBase64Encoded": false,
        "httpMethod": "POST",
        "path": "",
        "body": "test_cangjie"
    }
    Parameters must be transferred based on the APIGTriggerEvent class defined in the Yuanrong SDK. Otherwise, serialization and deserialization exceptions may occur.
    public open class APIGTriggerEvent {
        private var isBase64Encoded: Bool = false;
        private var httpMethod: String = "POST";
        private var path: String = "";
        private var body: String = "";
    }

  2. After the test event is configured, click Test.