Function orchestrateCloudEvents

  • Type Parameters

    • TLogic extends AnyActorLogic

    Parameters

    • param: IOrchestrateCloudEvents<TLogic>

      Parameters for orchestrating cloud events, including state machine logic, storage manager, and middleware.

    • events: CloudEvent<Record<string, any>>[] = []

      An array of CloudEvent objects to be processed during the orchestration.

    • inits: InitialOrchestrationEvent<TLogic>[] = []

      Optional. An array of initialization objects containing a subject (process ID) and initial context for actors.

    Returns Promise<{
        errors: {
            error: string;
            events?: CloudEvent<Record<string, any>>[];
            initEvents?: InitialOrchestrationEvent<TLogic>[];
        }[];
        eventsToEmit: CloudEvent<Record<string, any>>[];
        processContext: Record<string, {
            context?: ContextFrom<TLogic>;
            status?: string;
        }>;
    }>

    Promise resolving to an array of CloudEvent objects to be emitted as a result of the orchestration.

    Deprecated

    • Use createOrchestrationRouter instead Orchestrates cloud events by processing each event, managing the state with persistent actors, and emitting new cloud events based on the defined orchestration logic.

    Throws

    Error if any cloud event lacks a subject, or if there's an overlap in subjects between events and initialization objects.

    Example

    const orchestrationParams = {
    statemachine: [...], // Define state machines
    name: "ExampleOrchestrator", // Orchestrator name
    storageManager: someStorageManager, // Storage manager for persistent actors
    onOrchestrationState: (id, state) => { // middleware for handling orchestration state changes // },
    onCloudEvent: (id, event) => { // middleware for handling cloud events during orchestration // },
    onSnapshot: (id, snapshot) => { // callback for handling actor snapshots // },
    };
    const initialEvents = [
    { processId: "123", version: "v1.0", context: {} },
    // ... more initialization objects
    ];
    const cloudEvents = [
    { subject: "123", // cloud event data // },
    // ... more cloud events
    ];
    const result = await orchestrateCloudEvents(orchestrationParams, cloudEvents, initialEvents);
    console.log(result.eventsToEmit); // Array of CloudEvents to be emitted
    console.log(result.processContext); // Map of process IDs to their corresponding contexts
    console.log(result.errors); // Array of errors encountered during orchestration

Generated using TypeDoc