Event Introduction - JS/TS
Read and write the event store.
Logic Type | Available |
---|---|
Generic logic | ✅ |
Aggregator logic | ❌ |
A LOC event is a timestamped log or metadata representing a data flow, which can be read and write in LOC's event store (implemented with Elasticsearch).
The source and target digital identity (DID) are customised nodes defined by users. Multiple events with shared source/target nodes form a data lineage:
Import and Usage
- JavaScript
- TypeScript
import {
EventAgent,
} from "@fstnetwork/loc-logic-sdk";
export async function run(ctx) {
await EventAgent.emit([
{
labelName: "event",
sourceDID: "source",
targetDID: "target",
meta: "",
type: "default",
},
]);
}
export async function handleError(ctx, error) {
// ... same
}
import {
Event,
EventAgent,
GenericContext,
RailwayError,
} from "@fstnetwork/loc-logic-sdk";
export async function run(ctx: GenericContext) {
await EventAgent.emit([
{
labelName: "event",
sourceDID: "source",
targetDID: "target",
meta: "",
type: "default",
},
] as Event.Event[]);
}
export async function handleError(ctx: GenericContext, error: RailwayError) {
// ... same
}
Events Fields For Query
An event in the event store has the following field names that can be added in query, exclude, filter and sort conditions:
Field Name | Description |
---|---|
label_id | label ID |
label_name | Label name (labelName in emit() ) |
source_digital_identity | Source DID (sourceDID in emit() ) |
target_digital_identity | Target DID (targetDID in emit() ) |
type | Type (type in emit() ) |
timestamp | Event emitted time (unix timestamp) |
sequence | Event sequence number (the emit order in an array, starting from 0 ) |
execution_id | Execution ID |
task_id | Task ID |
data_process_permanent_identity | Data process permanent ID |
data_process_name | Data process name |
data_process_revision | Data process revision number |
logic_name | Logic name |
logic_permanent_identity | Logic permanent ID |
logic_revision | Logic revision number |
info
The sequence number represents the order of an event emitted in the array. If you emit 10 events at once, they will have sequence number from 1 to 10.
Class Reference
Type
EventAgent
Method: Emit Events
Refer to: Emit Events
Method: Search Events
Refer to: Search Events
Method: Search Event Sequences
Refer to: Search Event Sequences
Examples
See each method pages for their examples.