Interface IPersistStateInstance

Per-context state persistence instance interface. Scoped to a specific (signalId, bucketName) pair.

Used by StatePersistInstance for crash-safe strategy state storage. Custom adapters should implement this interface to override the default file-based state behavior.

interface IPersistStateInstance {
    dispose(): void;
    readStateData(): Promise<StateData>;
    waitForInit(initial: boolean): Promise<void>;
    writeStateData(data: StateData, when: Date): Promise<void>;
}

Implemented by

Methods

  • Release any resources held by this instance. Default implementations may treat this as a no-op.

    Returns void

  • Read persisted state for this context.

    Returns Promise<StateData>

    Promise resolving to state data or null if none persisted

  • Initialize storage for this state context.

    Parameters

    • initial: boolean

      Whether this is the first initialization

    Returns Promise<void>

    Promise that resolves when initialization is complete

  • Write state for this context.

    Parameters

    • data: StateData

      State data to persist (already carries data.when)

    • when: Date

      Logical timestamp this value belongs to (duplicates data.when for API consistency)

    Returns Promise<void>

    Promise that resolves when write is complete