@hotmeshio/hotmesh
Version:
Permanent-Memory Workflows & AI Agents
69 lines (68 loc) • 2.25 kB
TypeScript
import { ILogger } from '../../../logger';
import { KeyType } from '../../../../modules/key';
import { KeyStoreParams } from '../../../../types';
import { PostgresClientType } from '../../../../types/postgres';
import { ProviderClient } from '../../../../types/provider';
/**
* Scout state manager for coordinating polling across multiple instances.
* Only one instance at a time should be the active scout.
*/
export declare class ScoutManager {
private client;
private appId;
private getTableName;
private mintKey;
private logger;
private isScout;
private shouldStopScout;
private pollCount;
private totalNotifications;
private scoutStartTime;
constructor(client: PostgresClientType & ProviderClient, appId: string, getTableName: () => string, mintKey: (type: KeyType, params: KeyStoreParams) => string, logger: ILogger);
/**
* Start the router scout polling loop.
* Winner polls frequently for visible messages, losers retry acquiring role less frequently.
*/
startRouterScoutPoller(): void;
/**
* Stop the router scout polling loop and release the role.
*/
stopRouterScoutPoller(): Promise<void>;
/**
* Check if this instance should act as the router scout.
*/
private shouldScout;
/**
* Main polling loop for the router scout.
*/
private pollForVisibleMessagesLoop;
/**
* Poll for visible messages and trigger notifications for any found.
*/
private pollForVisibleMessages;
/**
* Reserve the router scout role using direct SQL.
*/
private reserveRouterScoutRole;
/**
* Reserve a scout role for the specified type.
* Uses SET NX (set if not exists) with expiration to ensure only one instance holds the role.
*/
private reserveScoutRole;
/**
* Release a scout role for the specified type.
*/
private releaseScoutRole;
/**
* Get the router scout polling interval in milliseconds.
*/
private getRouterScoutInterval;
/**
* Check if this instance is currently the scout.
*/
isCurrentlyScout(): boolean;
/**
* Log polling metrics for this instance's scout tenure.
*/
private logPollingMetrics;
}