/** * Base Transport Adapter * * Abstract base class for stream transport adapters. * Follows the adapter pattern used in @plyaz/storage. */ import type { StreamMessage, StreamTransportAdapterConfig, StreamTransportType } from '@plyaz/types/core'; /** * BaseTransportAdapter - Abstract base class for all transport adapters * * Provides: * - Common configuration handling * - Interface for connection management * - Message sending abstraction * * Subclasses must implement: * - createConnection() - Create new connection * - send() - Send message to connection * - close() - Close connection * - isAlive() - Check connection status * * @example * ```ts * class MyTransportAdapter extends BaseTransportAdapter { * async createConnection(connectionId: string, request: Request): Promise { * // Implementation * } * // ... other methods * } * ``` */ export declare abstract class BaseTransportAdapter { /** Adapter name for logging/debugging */ readonly name: string; /** Transport type identifier */ readonly type: StreamTransportType; /** Heartbeat interval in milliseconds */ protected readonly heartbeatInterval: number; /** Maximum concurrent connections */ protected readonly maxConnections: number; constructor(config: StreamTransportAdapterConfig & { type: StreamTransportType; }); /** * Create a new streaming connection * * For SSE: Returns a Response with streaming body * For WebSocket: Modifies socket directly, returns void * * @param connectionId - Unique connection identifier * @param request - HTTP request or WebSocket upgrade request * @returns Response for SSE, void for WebSocket */ abstract createConnection(connectionId: string, request: Request): Promise; /** * Send a message to a specific connection * * @param connectionId - Connection to send to * @param message - Message to send */ abstract send(connectionId: string, message: StreamMessage): Promise; /** * Close a connection * * @param connectionId - Connection to close */ abstract close(connectionId: string): Promise; /** * Check if a connection is still alive * * @param connectionId - Connection to check * @returns Whether connection is alive */ abstract isAlive(connectionId: string): boolean; /** * Get current connection count * * @returns Number of active connections */ abstract getConnectionCount(): number; /** * Get adapter info for debugging */ getAdapterInfo(): { name: string; type: StreamTransportType; heartbeatInterval: number; maxConnections: number; connectionCount: number; }; /** * Check if adapter can accept more connections */ canAcceptConnection(): boolean; } //# sourceMappingURL=BaseTransportAdapter.d.ts.map