Skip to content

@codesoul-co/hypha-core / modules/runtime/session-queue

Using this module

Use the Session queue module for executing runtime behavior at this boundary. It exports 1 class, 1 function, 2 interfaces.

Import from the package entrypoint

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

import type {
  InMemorySessionQueueOptions,
  SessionQueue,
} from '@codesoul-co/hypha-core';

Usage patterns

  • Use the 2 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.
  • The module exposes 1 function as direct operation entrypoints. Every overload, required/optional parameter, and return type is documented below.

Public exports

SymbolKindSignatureDescription
InMemorySessionQueueclassnew InMemorySessionQueue(options?: InMemorySessionQueueOptions): InMemorySessionQueueIn Memory Session Queue class with 14 public constructor or member entries; its exact declarations are listed below.
createSessionQueueHealthSnapshotfunctioncreateSessionQueueHealthSnapshot(records: readonly SessionCommandRecord[], checkedAt: string, recoveredExpiredLeases?: number): SessionQueueHealthSnapshotCreate Session Queue Health Snapshot function with 1 public call signature; parameters and return types are listed below.
InMemorySessionQueueOptionsinterfaceinterface InMemorySessionQueueOptionsIn Memory Session Queue Options interface with 8 public fields or methods.
SessionQueueinterfaceinterface SessionQueueSession Queue interface with 13 public fields or methods.

InMemorySessionQueue

In Memory Session Queue class with 14 public constructor or member entries; its exact declarations are listed below.

Declaration

text
export declare class InMemorySessionQueue implements SessionQueue {
    constructor(options?: InMemorySessionQueueOptions);
    enqueue(request: EnqueueSessionCommandRequest): Promise<SessionCommandRecord>;
    claim(request: ClaimSessionCommandRequest): Promise<SessionCommandRecord | null>;
    renew(request: RenewSessionCommandRequest): Promise<SessionCommandClaim>;
    complete(request: CompleteSessionCommandRequest): Promise<void>;
    fail(request: FailSessionCommandRequest): Promise<void>;
    release(request: ReleaseSessionCommandRequest): Promise<void>;
    list(request: ListSessionCommandsRequest): Promise<SessionCommandRecord[]>;
    cancelPending(request: CancelSessionCommandsRequest): Promise<CancelSessionCommandsResult>;
    redriveDeadLetter(request: RedriveDeadLetterSessionCommandRequest): Promise<SessionCommandRecord>;
    closeDeadLetter(request: CloseDeadLetterSessionCommandRequest): Promise<SessionCommandRecord>;
    listStuck(request: ListStuckSessionCommandsRequest): Promise<StuckSessionCommand[]>;
    drain(scope: SessionQueueScope): Promise<void>;
    health(): Promise<ProviderHealth & {
            details: SessionQueueHealthSnapshot;
        }>;
}

Public members

MemberKindSignatureDescription
cancelPendingmethodcancelPending(request: CancelSessionCommandsRequest): Promise<CancelSessionCommandsResult>Public method; parameters and return type are shown in the signature.
claimmethodclaim(request: ClaimSessionCommandRequest): Promise<SessionCommandRecord | null>Public method; parameters and return type are shown in the signature.
closeDeadLettermethodcloseDeadLetter(request: CloseDeadLetterSessionCommandRequest): Promise<SessionCommandRecord>Public method; parameters and return type are shown in the signature.
completemethodcomplete(request: CompleteSessionCommandRequest): Promise<void>Public method; parameters and return type are shown in the signature.
constructorconstructor(options?: InMemorySessionQueueOptions): InMemorySessionQueueCreates an instance of this class.
drainmethoddrain(scope: SessionQueueScope): Promise<void>Public method; parameters and return type are shown in the signature.
enqueuemethodenqueue(request: EnqueueSessionCommandRequest): Promise<SessionCommandRecord>Public method; parameters and return type are shown in the signature.
failmethodfail(request: FailSessionCommandRequest): Promise<void>Public method; parameters and return type are shown in the signature.
healthmethodhealth(): Promise<ProviderHealth & { details: SessionQueueHealthSnapshot; }>Public method; parameters and return type are shown in the signature.
listmethodlist(request: ListSessionCommandsRequest): Promise<SessionCommandRecord[]>Public method; parameters and return type are shown in the signature.
listStuckmethodlistStuck(request: ListStuckSessionCommandsRequest): Promise<StuckSessionCommand[]>Public method; parameters and return type are shown in the signature.
redriveDeadLettermethodredriveDeadLetter(request: RedriveDeadLetterSessionCommandRequest): Promise<SessionCommandRecord>Public method; parameters and return type are shown in the signature.
releasemethodrelease(request: ReleaseSessionCommandRequest): Promise<void>Public method; parameters and return type are shown in the signature.
renewmethodrenew(request: RenewSessionCommandRequest): Promise<SessionCommandClaim>Public method; parameters and return type are shown in the signature.

createSessionQueueHealthSnapshot

Create Session Queue Health Snapshot function with 1 public call signature; parameters and return types are listed below.

Declaration

text
export declare function createSessionQueueHealthSnapshot(records: readonly SessionCommandRecord[], checkedAt: string, recoveredExpiredLeases?: number): SessionQueueHealthSnapshot;

Call signature

text
createSessionQueueHealthSnapshot(records: readonly SessionCommandRecord[], checkedAt: string, recoveredExpiredLeases?: number): SessionQueueHealthSnapshot

Parameters

ParameterTypeRequiredDescription
recordsreadonly SessionCommandRecord[]YesRequired parameter; accepted values are defined by the type column.
checkedAtstringYesRequired parameter; accepted values are defined by the type column.
recoveredExpiredLeasesnumberNoOptional parameter; accepted values are defined by the type column.

Returns

  • Type: SessionQueueHealthSnapshot
  • Description: The return contract is defined by the type shown above.

InMemorySessionQueueOptions

In Memory Session Queue Options interface with 8 public fields or methods.

Declaration

text
export interface InMemorySessionQueueOptions {
    now?: () => string;
    duplicatePolicy?: 'reuse' | 'reject';
    maxPendingPerSession?: number;
    maxPendingPerUser?: number;
    maxPendingGlobal?: number;
    maxConcurrentSessions?: number;
    maxConcurrentSessionsPerUser?: number;
    priorityAgingMs?: number;
}

Contract members

MemberKindSignatureDescription
duplicatePolicypropertyduplicatePolicy?: "reuse" | "reject"Public property; its type, readonly modifier and optionality are shown in the signature.
maxConcurrentSessionspropertymaxConcurrentSessions?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
maxConcurrentSessionsPerUserpropertymaxConcurrentSessionsPerUser?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
maxPendingGlobalpropertymaxPendingGlobal?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
maxPendingPerSessionpropertymaxPendingPerSession?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
maxPendingPerUserpropertymaxPendingPerUser?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
nowmethodnow?(): stringPublic method; parameters and return type are shown in the signature.
priorityAgingMspropertypriorityAgingMs?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.

SessionQueue

Session Queue interface with 13 public fields or methods.

Declaration

text
export interface SessionQueue {
    enqueue(request: EnqueueSessionCommandRequest): Promise<SessionCommandRecord>;
    claim(request: ClaimSessionCommandRequest): Promise<SessionCommandRecord | null>;
    renew(request: RenewSessionCommandRequest): Promise<SessionCommandClaim>;
    complete(request: CompleteSessionCommandRequest): Promise<void>;
    fail(request: FailSessionCommandRequest): Promise<void>;
    release(request: ReleaseSessionCommandRequest): Promise<void>;
    list(request: ListSessionCommandsRequest): Promise<SessionCommandRecord[]>;
    cancelPending(request: CancelSessionCommandsRequest): Promise<CancelSessionCommandsResult>;
    redriveDeadLetter(request: RedriveDeadLetterSessionCommandRequest): Promise<SessionCommandRecord>;
    closeDeadLetter(request: CloseDeadLetterSessionCommandRequest): Promise<SessionCommandRecord>;
    listStuck(request: ListStuckSessionCommandsRequest): Promise<StuckSessionCommand[]>;
    drain(scope: SessionQueueScope): Promise<void>;
    health(): Promise<ProviderHealth & {
        details: SessionQueueHealthSnapshot;
    }>;
}

Contract members

MemberKindSignatureDescription
cancelPendingmethodcancelPending(request: CancelSessionCommandsRequest): Promise<CancelSessionCommandsResult>Public method; parameters and return type are shown in the signature.
claimmethodclaim(request: ClaimSessionCommandRequest): Promise<SessionCommandRecord | null>Public method; parameters and return type are shown in the signature.
closeDeadLettermethodcloseDeadLetter(request: CloseDeadLetterSessionCommandRequest): Promise<SessionCommandRecord>Public method; parameters and return type are shown in the signature.
completemethodcomplete(request: CompleteSessionCommandRequest): Promise<void>Public method; parameters and return type are shown in the signature.
drainmethoddrain(scope: SessionQueueScope): Promise<void>Public method; parameters and return type are shown in the signature.
enqueuemethodenqueue(request: EnqueueSessionCommandRequest): Promise<SessionCommandRecord>Public method; parameters and return type are shown in the signature.
failmethodfail(request: FailSessionCommandRequest): Promise<void>Public method; parameters and return type are shown in the signature.
healthmethodhealth(): Promise<ProviderHealth & { details: SessionQueueHealthSnapshot; }>Public method; parameters and return type are shown in the signature.
listmethodlist(request: ListSessionCommandsRequest): Promise<SessionCommandRecord[]>Public method; parameters and return type are shown in the signature.
listStuckmethodlistStuck(request: ListStuckSessionCommandsRequest): Promise<StuckSessionCommand[]>Public method; parameters and return type are shown in the signature.
redriveDeadLettermethodredriveDeadLetter(request: RedriveDeadLetterSessionCommandRequest): Promise<SessionCommandRecord>Public method; parameters and return type are shown in the signature.
releasemethodrelease(request: ReleaseSessionCommandRequest): Promise<void>Public method; parameters and return type are shown in the signature.
renewmethodrenew(request: RenewSessionCommandRequest): Promise<SessionCommandClaim>Public method; parameters and return type are shown in the signature.