Utility class for managing session persistence.
Features:
Storage layout: ./dump/session/<strategyName>/<exchangeName>/<frameName>.json
Used by SessionPersistInstance for crash-safe session persistence.
constructor();
PersistSessionInstanceCtor: any
Constructor used to create per-context session instances. Replaceable via usePersistSessionAdapter() / useJson() / useDummy().
getSessionStorage: any
Memoized factory creating one IPersistSessionInstance per (strategyName, exchangeName, frameName) triple.
waitForInit: (strategyName: string, exchangeName: string, frameName: string, initial: boolean) => Promise<void>
Initializes the session storage for the given context.
Skips initialization when initial is false (used to gate first-time setup).
readSessionData: (strategyName: string, exchangeName: string, frameName: string) => Promise<SessionData>
Reads persisted session data for the given context. Lazily initializes the instance on first access.
writeSessionData: (data: SessionData, strategyName: string, exchangeName: string, frameName: string, when: Date) => Promise<void>
Writes session data for the given context. Lazily initializes the instance on first access.
useDummy: () => void
Switches to PersistSessionDummyInstance (all operations are no-ops).
useJson: () => void
Switches to the default file-based PersistSessionInstance.
clear: () => void
Clears the memoized instance cache. Call when process.cwd() changes between strategy iterations.
dispose: (strategyName: string, exchangeName: string, frameName: string) => void
Drops the memoized instance for the given context. Call when a session is removed to clean up its associated storage entry.
usePersistSessionAdapter(Ctor: TPersistSessionInstanceCtor): void;
Registers a custom IPersistSessionInstance constructor. Clears the memoization cache so subsequent calls use the new adapter.