interface Endpoint { host: string; port: number; remote: boolean; } interface EndpointInput { host: string; port: number; remote?: boolean; } interface WrappedEntry { key: string; host: string; port: number; remote: boolean; } interface RoutingStrategy { pick(entries: WrappedEntry[], callContext?: unknown): WrappedEntry | WrappedEntry[] | null; acquire?(endpointKey: string): void; release?(endpointKey: string): void; } export declare class EndpointResolver { private _endpoints; private _counters; private _strategies; private _wrappedCache; private _healthStatus; private _failureCounts; private _failureThreshold; constructor(); /** * Set a routing strategy for a specific service. * When set, resolve() delegates to the strategy's pick() method * instead of using built-in round-robin. * * The strategy must implement pick(entries, callContext) where entries * are wrapped as { key: "host:port", host, port, remote }. */ setStrategy(serviceName: string, strategy: RoutingStrategy): void; /** * Create an EndpointResolver from environment variables. * * Parses FORGE_SERVICE_ENDPOINTS first (full endpoint map with host/port/remote). * Falls back to FORGE_SERVICE_PORTS (localhost-only port map) when endpoints * aren't available. */ static fromEnv(): EndpointResolver; /** * Resolve an endpoint for a service. * Delegates to a configured RoutingStrategy when available, * otherwise round-robins across instances. */ resolve(serviceName: string, callContext?: unknown): Endpoint | Endpoint[] | null; /** * Get all endpoints for a service (used for broadcast/event delivery). */ all(serviceName: string): Endpoint[]; /** * Add or update an endpoint for a service. * Used by dynamic registry discovery. */ set(serviceName: string, endpoint: EndpointInput): void; /** * Remove a specific instance of a service. * Used when a remote node goes down. */ remove(serviceName: string, host: string, port: number): void; /** * COR-C1: Acquire a pending slot for a resolved endpoint. * Delegates to the service's routing strategy if it supports acquire(). * Must be paired with releaseEndpoint() in a finally block. */ acquireEndpoint(serviceName: string, endpointKey: string): void; /** * COR-C1: Release a pending slot for a resolved endpoint. * Delegates to the service's routing strategy if it supports release(). */ releaseEndpoint(serviceName: string, endpointKey: string): void; /** * REG-H2: Update health status for a specific endpoint. * Called when the Supervisor pushes health updates or on connection failure feedback. */ setHealthStatus(host: string, port: number, status: 'healthy' | 'degraded' | 'unhealthy' | 'draining'): void; /** * REG-H2: Get the health status of a specific endpoint. */ getHealthStatus(host: string, port: number): string; /** * REG-M2: Record a connection failure for an endpoint. * After _failureThreshold consecutive failures, the endpoint is marked unhealthy. * Returns the current consecutive failure count. */ recordFailure(host: string, port: number): number; /** * REG-M2: Record a successful connection to an endpoint. * Resets the consecutive failure counter and marks the endpoint healthy. */ recordSuccess(host: string, port: number): void; /** * Check if a service has any known endpoints. */ has(serviceName: string): boolean; /** * REG-H1: Apply a full endpoint map update (pushed from Supervisor). * Merges new/updated endpoints and removes stale ones not present in the update. * Only updates remote endpoints to avoid overwriting local colocated/UDS entries. */ applyEndpointUpdate(endpointMap: Record): void; } export {}; //# sourceMappingURL=EndpointResolver.d.ts.map