Context and Task
Data Context is an object injected into logic functions at runtime, which containes some key components:
Availability
- ✓ Generic logic
- ✓ Aggregator logic
Context
Type:
GenericContext
(generic logic)AggregatorContext
(aggregator logic)
When a logic gets executed, a data context object ctx
will be available in both run
and handleError
functions:
- JavaScript
- TypeScript
export async function run(ctx) {
// ctx is the data context
}
export async function handleError(ctx, error) {
// the same context as well as error
}
import { GenericContext, RailwayError } from "@fstnetwork/loc-logic-sdk";
export async function run(ctx: GenericContext) {
// ctx is the data context
}
export async function handleError(ctx: GenericContext, error: RailwayError) {
// the same context as well as error
}
Task
export async function run(ctx) {
const task = ctx.task;
}
A task is an execution of this particular data process invoked by a trigger.
Member | Type | Description |
---|---|---|
taskId | taskId , which is { id: string, executionId: string } | Task ID and execution ID |
startAt | Date | Task start date |
dataProcess | VersionedIdentityContext | Data process permanent ID |
currentLogic | VersionedIdentityContext | Current logic permanent ID |
executedLogics | Array<VersionedIdentityContext> | An array of identity of executed logic |
Versioned Identity Context
Represents the identity of a logic or a data process:
Member | Type | Description |
---|---|---|
name | string | Name |
permanentIdentity | string | Permanent identity string (PID) |
revision | number | Revision number |
Example
const taskId = ctx.task.taskId.id;
const executionId = ctx.task.taskId.executionId;
const pid = ctx.task.dataProcess.permanentIdentity;