UNPKG

@hotmeshio/hotmesh

Version:

Permanent-Memory Workflows & AI Agents

59 lines (58 loc) 2.91 kB
/// <reference types="node" /> import { ILogger } from '../logger'; import { StreamService } from '../stream'; import { RouterConfig, StreamData, StreamDataResponse, StreamRole } from '../../types/stream'; import { ProviderClient, ProviderTransaction } from '../../types/provider'; declare class Router<S extends StreamService<ProviderClient, ProviderTransaction>> { appId: string; guid: string; role: StreamRole; topic: string | undefined; stream: S; reclaimDelay: number; reclaimCount: number; logger: ILogger; readonly: boolean; retryPolicy: import('../../types/stream').RetryPolicy | undefined; errorCount: number; counts: { [key: string]: number; }; hasReachedMaxBackoff: boolean | undefined; currentTimerId: NodeJS.Timeout | null; sleepPromiseResolve: (() => void) | null; innerPromiseResolve: (() => void) | null; isSleeping: boolean; sleepTimout: NodeJS.Timeout | null; private isUsingNotifications; private throttleManager; private errorHandler; private lifecycleManager; private consumptionManager; constructor(config: RouterConfig, stream: S, logger: ILogger); get throttle(): number; get shouldConsume(): boolean; set shouldConsume(value: boolean); private resetThrottleState; createGroup(stream: string, group: string): Promise<void>; publishMessage(topic: string, streamData: StreamData | StreamDataResponse, transaction?: ProviderTransaction): Promise<string | ProviderTransaction>; customSleep(): Promise<void>; consumeMessages(stream: string, group: string, consumer: string, callback: (streamData: StreamData) => Promise<StreamDataResponse | void>): Promise<void>; isStreamMessage(result: any): boolean; isPaused(): boolean; isStopped(group: string, consumer: string, stream: string): boolean; consumeOne(stream: string, group: string, id: string, input: StreamData, callback: (streamData: StreamData) => Promise<StreamDataResponse | void>): Promise<void>; execStreamLeg(input: StreamData, stream: string, id: string, callback: (streamData: StreamData) => Promise<StreamDataResponse | void>): Promise<StreamDataResponse>; ackAndDelete(stream: string, group: string, id: string): Promise<void>; publishResponse(input: StreamData, output: StreamDataResponse | void): Promise<string>; shouldRetry(input: StreamData, output: StreamDataResponse): [boolean, number]; structureUnhandledError(input: StreamData, err: Error): StreamDataResponse; structureUnacknowledgedError(input: StreamData): StreamDataResponse; structureError(input: StreamData, output: StreamDataResponse): StreamDataResponse; static stopConsuming(): Promise<void>; stopConsuming(): Promise<void>; cancelThrottle(): void; setThrottle(delayInMillis: number): void; static get instances(): Set<Router<any>>; } export { Router };