UNPKG

@stalkchain/grpc-pool

Version:

High-availability gRPC connection pooling module with active-active configuration, deduplication, and stale connection detection

81 lines 2.33 kB
/** * lib/client.ts - Individual gRPC client wrapper * * Wraps a single Triton-One Yellowstone gRPC connection with simple interface. * Handles connection, subscription, and streaming for one endpoint. * Includes infinite retry mechanism and stale connection detection. * * @module lib/client * @author StalkChain Team * @version 1.1.1 */ import { EventEmitter } from 'events'; import { PoolEndpoint } from '../types'; /** * Simple wrapper for a single gRPC client with infinite retry and stale detection */ export declare class GrpcClient extends EventEmitter { private client; private endpoint; private connected; private stream; private retryAttempts; private retryTimeout; private lastMessageTimestamp; private currentSubscription; private config; constructor(endpoint: PoolEndpoint, options?: { staleTimeoutMs?: number; initialRetryDelayMs?: number; maxRetryDelayMs?: number; retryBackoffFactor?: number; }); /** * Connect to the gRPC endpoint with infinite retry mechanism */ connect(): Promise<void>; /** * Check if connection is stale (no messages received for too long) */ isStale(): boolean; /** * Clean up existing connection resources properly * * This method safely closes streams and clients while preserving the * subscription state, which should persist across reconnections. */ private cleanupConnection; /** * Force reconnection for stale connections */ forceReconnect(): Promise<void>; /** * Schedule infinite retry with exponential backoff (500ms to 30s max) */ private scheduleRetry; /** * Subscribe using full subscription request object */ subscribe(subscribeRequest: any): Promise<void>; /** * Send ping if enabled for this endpoint */ ping(id: number): Promise<void>; /** * Close the client connection and clear any retry timeouts */ close(): Promise<void>; /** * Check if client is connected */ isConnected(): boolean; /** * Get endpoint info */ getEndpoint(): PoolEndpoint; /** * Get time since last message in milliseconds */ getTimeSinceLastMessage(): number; } //# sourceMappingURL=client.d.ts.map