Context and Task
Data Context is an object injected into logic functions during a task, which containes some key components:
- Task and execution-related information
- Trigger payload
- Agents (data operation functionalities)
Availability
- ✓ Generic logic
- ✓ Aggregator logic
Context
When a logic gets executed, a data context object ctx
will be available in both run
and handleError
functions:
async function run(ctx) {
// ctx is the data context
}
note
Logic functions in CLI must add export
for the compiling process:
export async function run(ctx) {}
Task
ctx.task;
Member | Type | Description |
---|---|---|
taskId | taskId , which is { id: string, executionId: string } | Task ID and execution ID |
startAt | Date | Task start date |
dataProcess | IdentityContext | Data process permanent ID |
currentLogic | IdentityContext | Current logic permanent ID |
executedLogics | Array<IdentityContext> | An array of identity of executed logic |
Type IdentityContext
represents the identity of a logic or a data process:
Member | Type | Description |
---|---|---|
name | string | Name |
permanentIdentity | string | Permanent identity string |
revision | number | Revision number |
Example
const taskId = ctx.task.taskId.id;
const executionId = ctx.task.taskId.executionId;
const pid = ctx.task.dataProcess.permanentIdentity;