Skip to content

@codesoul-co/hypha-core / modules/runtime/session-command-scheduler

Using this module

Use the Session command scheduler module for executing runtime behavior at this boundary. It exports 1 class, 4 interfaces.

Import from the package entrypoint

ts
import {
  DurableSessionCommandScheduler,
} from '@codesoul-co/hypha-core';

import type {
  DurableSessionCommandSchedulerOptions,
  RunSessionCommandSchedulerRequest,
  SessionCommandProcessor,
  SessionCommandSchedulerResult,
} from '@codesoul-co/hypha-core';

Usage patterns

  • Use the 4 type/interface exports as static contracts in application code, adapters, or tests. Import them with import type; they do not exist at runtime.
  • The module exposes 1 class as constructable runtime implementations. Each symbol entry lists its constructor and public methods.

Public exports

SymbolKindSignatureDescription
DurableSessionCommandSchedulerclassnew DurableSessionCommandScheduler(options: DurableSessionCommandSchedulerOptions): DurableSessionCommandSchedulerRepeatedly invokes a single-command processor until shutdown is requested. Abort stops new claims, wakes idle waits, and lets an in-flight handler drain.
DurableSessionCommandSchedulerOptionsinterfaceinterface DurableSessionCommandSchedulerOptionsDurable Session Command Scheduler Options interface with 7 public fields or methods.
RunSessionCommandSchedulerRequestinterfaceinterface RunSessionCommandSchedulerRequestRun Session Command Scheduler Request interface with 2 public fields or methods.
SessionCommandProcessorinterfaceinterface SessionCommandProcessorSession Command Processor interface with 1 public fields or methods.
SessionCommandSchedulerResultinterfaceinterface SessionCommandSchedulerResultSession Command Scheduler Result interface with 3 public fields or methods.

DurableSessionCommandScheduler

Repeatedly invokes a single-command processor until shutdown is requested. Abort stops new claims, wakes idle waits, and lets an in-flight handler drain.

Declaration

text
export declare class DurableSessionCommandScheduler {
    constructor(options: DurableSessionCommandSchedulerOptions);
    run(request: RunSessionCommandSchedulerRequest): Promise<SessionCommandSchedulerResult>;
}

Public members

MemberKindSignatureDescription
constructorconstructor(options: DurableSessionCommandSchedulerOptions): DurableSessionCommandSchedulerCreates an instance of this class.
runmethodrun(request: RunSessionCommandSchedulerRequest): Promise<SessionCommandSchedulerResult>Public method; parameters and return type are shown in the signature.

DurableSessionCommandSchedulerOptions

Durable Session Command Scheduler Options interface with 7 public fields or methods.

Declaration

text
export interface DurableSessionCommandSchedulerOptions {
    worker: SessionCommandProcessor;
    pollIntervalMs?: number;
    errorBackoffMs?: number;
    shutdownDrainMs?: number;
    wait?: (delayMs: number, signal: AbortSignal) => Promise<void>;
    onResult?: (result: SessionCommandWorkerResult) => void;
    onError?: (error: unknown) => void;
}

Contract members

MemberKindSignatureDescription
errorBackoffMspropertyerrorBackoffMs?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
onErrormethodonError?(error: unknown): voidPublic method; parameters and return type are shown in the signature.
onResultmethodonResult?(result: SessionCommandWorkerResult): voidPublic method; parameters and return type are shown in the signature.
pollIntervalMspropertypollIntervalMs?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
shutdownDrainMspropertyshutdownDrainMs?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
waitmethodwait?(delayMs: number, signal: AbortSignal): Promise<void>Public method; parameters and return type are shown in the signature.
workerpropertyworker: SessionCommandProcessorPublic property; its type, readonly modifier and optionality are shown in the signature.

RunSessionCommandSchedulerRequest

Run Session Command Scheduler Request interface with 2 public fields or methods.

Declaration

text
export interface RunSessionCommandSchedulerRequest {
    signal: AbortSignal;
    scope?: SessionQueueScope;
}

Contract members

MemberKindSignatureDescription
scopepropertyscope?: SessionQueueScopePublic property; its type, readonly modifier and optionality are shown in the signature.
signalpropertysignal: AbortSignalPublic property; its type, readonly modifier and optionality are shown in the signature.

SessionCommandProcessor

Session Command Processor interface with 1 public fields or methods.

Declaration

text
export interface SessionCommandProcessor {
    processNext(scope?: SessionQueueScope, signal?: AbortSignal): Promise<SessionCommandWorkerResult>;
}

Contract members

MemberKindSignatureDescription
processNextmethodprocessNext(scope?: SessionQueueScope, signal?: AbortSignal): Promise<SessionCommandWorkerResult>Public method; parameters and return type are shown in the signature.

SessionCommandSchedulerResult

Session Command Scheduler Result interface with 3 public fields or methods.

Declaration

text
export interface SessionCommandSchedulerResult {
    processed: number;
    idlePolls: number;
    errors: number;
}

Contract members

MemberKindSignatureDescription
errorspropertyerrors: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
idlePollspropertyidlePolls: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
processedpropertyprocessed: numberPublic property; its type, readonly modifier and optionality are shown in the signature.