Type alias OnOrchestrationState

OnOrchestrationState: ((id, state, snapshot) => {
    data?: Record<string, any>;
    type: string;
})

Middleware function type for handling orchestration logic based on state and snapshot data. This function takes the current state and a machine snapshot, and returns data to create a CloudEvent representing the necessary actions or information for cloud-based orchestration.

Type declaration

    • (id, state, snapshot): {
          data?: Record<string, any>;
          type: string;
      }
    • Parameters

      • id: string

        The unique identifier for the orchestration actor.

      • state: string

        The current state of the machine.

      • snapshot: AnyMachineSnapshot

        The snapshot of the machine, providing a detailed view of its current state.

      Returns {
          data?: Record<string, any>;
          type: string;
      }

      • Optional data?: Record<string, any>
      • type: string

Returns

An object containing the type of the event, and optionally, additional data. The type ideally must be the topic of the event e.g. cmd.books.fetch, evt.books.fetch.success, notif.orch.done

Example

// Example middleware function for handling orchestration based on state and snapshot.
const onOrchestrationState: OnOrchestrationState = (id, state, snapshot) => {
return {
type: 'evt.books.fetch.success',
data: { orchestrationId: id, status: 'completed', snapshot },
};
};

Generated using TypeDoc