import type { FlowcoreEvent } from "../../contracts/event.js"; import type { Logger } from "../logger.js"; import type { PathwayPumpOptions, PumpState } from "./types.js"; /** * Registered pathway info needed for pump grouping. * `pumpGroup` defaults to `"default"` when omitted. */ interface PathwayRegistration { flowType: string; eventType: string; pumpGroup?: string; } /** * Filter for {@link PathwayPump.reset}. Each criterion narrows which pumps are reset. * - Omit both → reset every pump. * - `flowTypes` → reset every pump whose flow type matches. * - `pumpGroups` → reset every pump whose pump group matches. * - Both → reset pumps that match BOTH (intersection). */ export interface PumpResetFilter { flowTypes?: string[]; pumpGroups?: string[]; } /** * PathwayPump orchestrates data pump instances for auto-fetching events from Flowcore. * * Groups registered pathways by `(flowType, pumpGroup)` and creates one FlowcoreDataPump * per group. Within one `flowType`, multiple `pumpGroup`s give independent state cursors, * processor concurrency, and restart backoff. Events are routed to PathwaysBuilder.process() * for handling. * * Resilience: per-group restarts on error use exponential backoff and keep retrying * indefinitely (capped at {@link RESTART_MAX_MS}). A failure during a restart attempt * does NOT stop further attempts — the loop continues until the pump is explicitly stopped * or the restart eventually succeeds. */ export declare class PathwayPump { private readonly stateManagerFactory; private readonly notifier; private readonly bufferSize; private readonly maxRedeliveryCount; private readonly concurrency; private readonly logger; private readonly stateManagerFactoryArity; private legacyFactoryWarningEmitted; private pulseConfig?; private pumps; private stateManagers; private running; private restartAttempts; private restartTimers; private groupMeta; private dataPumpConstructor; private tenant; private dataCore; private apiKey; private baseUrl; private processEvent; constructor(options: PathwayPumpOptions, logger?: Logger); /** * Configure the pump with pathway builder context */ configure(config: { tenant: string; dataCore: string; apiKey: string; baseUrl: string; processEvent: (pathway: string, event: FlowcoreEvent) => Promise; }): void; /** * Start pumps for the given pathway registrations. * Groups by `(flowType, pumpGroup)` and creates one pump per group. */ start(pathways: PathwayRegistration[]): Promise; /** * Resolve a state manager for a `(flowType, pumpGroup)` pair, falling back to * the legacy single-arg factory shape when the user-supplied factory has arity 1. */ private resolveStateManager; /** * Resolve effective concurrency for one pump. * Order: `byPumpGroup` → `byFlowType` → `default`. */ private resolveConcurrency; /** * Start (or restart) a pump for a specific (flowType, pumpGroup) group. * * On error from the underlying pump, schedules an exponential-backoff restart * scoped to this group only. Restart attempts continue indefinitely (capped at * {@link RESTART_MAX_MS}); a synchronous failure during a restart attempt does * not stop the loop — it schedules another attempt. */ private startPumpForGroup; /** * Schedule a restart for one pump group with capped exponential backoff. * Multiple restart triggers for the same group within the backoff window are deduped. * A synchronous failure inside the scheduled restart re-arms another attempt — the * loop continues until the group is stopped or a restart succeeds. */ private scheduleRestart; /** * Stop all running pumps */ stop(): Promise; /** * Reset pumps to a specific position, or clear state and bounce if no position given. * Uses @flowcore/data-pump's restart() to reposition the cursor without recreating instances. * * Filter accepts: * - `string[]` → legacy: filter by flow type names * - `{ flowTypes?, pumpGroups? }` → narrow to matching `(flowType, pumpGroup)` pumps * * Both are supported for back-compat; the array form is equivalent to `{ flowTypes }`. * * @param position - Target position { timeBucket, eventId? }. If omitted, clears persisted state * and restarts pumps (pump will start from live position). * To replay from the very beginning, pass the first time bucket explicitly. * @returns Array of `${flowType}::${pumpGroup}` keys for pumps that were reset. */ reset(position?: PumpState, filter?: string[] | PumpResetFilter): Promise; setPulseConfig(pulseConfig: NonNullable): Promise; get isRunning(): boolean; /** * Unique flow types currently driven by at least one pump (back-compat with pre-2.4 API). */ get registeredFlowTypes(): string[]; /** * All `(flowType, pumpGroup)` pairs currently driven by a pump. */ get registeredPumpGroups(): Array<{ flowType: string; pumpGroup: string; }>; /** * Translate our notifier config into the exact shape `@flowcore/data-pump` reads. * * The pump discriminates on `notifier.type` and pulls `servers` / `intervalMs` off the * matching variant. `auth` and `dataSource` come from the top-level pump options, not * from here — anything extra placed on the notifier object is ignored. * * Emitting any other shape is silent: both discriminator checks resolve to `undefined` * and every pump falls through to the websocket notifier regardless of what the caller * configured. Keep this in lockstep with `FlowcoreDataPumpNotifierOptions`. */ private buildNotifierOptions; } export {}; //# sourceMappingURL=pathway-pump.d.ts.map