Event functions can be triggered when objects, such as files, are uploaded to Storage. For example, when a CSV file is uploaded to Storage, that event can trigger the Event function to parse the file and execute business logic.
1. Login to the ADP console and select the "Function" -> "Editor" menu.
2. Enter the details of the function, and click the "SAVE" button.
Name : Name of the function
Description : Description of the function
Function Type : Event
Datasource : The data source from which events originate
Cluster : The cluster where the function runs
Dedup : Event deduplication (true or false)
Since the Event function is executed at least once, setting "Dedup" to "false" may, in rare cases, result in the same event being processed multiple times.
When "Dedup" is set to "true", duplicate events are eliminated; however, if an identical object is uploaded multiple times, it will be treated as a single event, and subsequent events will not be triggered.
3. (Optional) Click on the Attach File button to attach a custom Python package to the function as a Zip file.
* AI models can be included in the package and loaded from within the function.
4. Enter any Python program in the text area.
The sample code on the left uses the “object” and “dsname” arguments passed to the Event function to download an object from the data source and log its file size.
5. Click the "SAVE" button to save the function.
The following is a list of functions and objects that can be used in the Event function.
path : Directory where custom packages are located
log(string) : Output function to execution log
upload(string) : Function to upload locally located files to Storage
Note :
It is also possible to associate multiple event functions with the same datasource.
If multiple objects are uploaded sequentially to the data source being processed by the event, the order in which the events occur is not guaranteed.