import { Observable, Observer, ReplaySubject } from 'rxjs'; import { ClientOptions, MsPattern, PacketId, ReadPacket, WritePacket } from '../interfaces'; import { ProducerDeserializer } from '../interfaces/deserializer.interface'; import { ProducerSerializer } from '../interfaces/serializer.interface'; /** * @publicApi */ export declare abstract class ClientProxy = Record, Status extends string = string> { protected routingMap: Map; protected serializer: ProducerSerializer; protected deserializer: ProducerDeserializer; protected _status$: ReplaySubject; /** * Returns an observable that emits status changes. */ get status(): Observable; /** * Establishes the connection to the underlying server/broker. */ abstract connect(): Promise; /** * Closes the underlying connection to the server/broker. */ abstract close(): any; /** * Registers an event listener for the given event. * @param event Event name * @param callback Callback to be executed when the event is emitted */ on(event: EventKey, callback: EventCallback): void; /** * Returns an instance of the underlying server/broker instance, * or a group of servers if there are more than one. */ abstract unwrap(): T; /** * Send a message to the server/broker. * Used for message-driven communication style between microservices. * @param pattern Pattern to identify the message * @param data Data to be sent * @returns Observable with the result */ send(pattern: any, data: TInput): Observable; /** * Emits an event to the server/broker. * Used for event-driven communication style between microservices. * @param pattern Pattern to identify the event * @param data Data to be sent * @returns Observable that completes when the event is successfully emitted */ emit(pattern: any, data: TInput): Observable; protected abstract publish(packet: ReadPacket, callback: (packet: WritePacket) => void): () => void; protected abstract dispatchEvent(packet: ReadPacket): Promise; protected createObserver(observer: Observer): (packet: WritePacket) => void; protected serializeError(err: any): any; protected serializeResponse(response: any): any; protected assignPacketId(packet: ReadPacket): ReadPacket & PacketId; protected connect$(instance: any, errorEvent?: string, connectEvent?: string): Observable; protected getOptionsProp(obj: Options, prop: Attribute): Options[Attribute]; protected getOptionsProp(obj: Options, prop: Attribute, defaultValue: DefaultValue): Required[Attribute]; protected normalizePattern(pattern: MsPattern): string; protected initializeSerializer(options: ClientOptions['options']): void; protected initializeDeserializer(options: ClientOptions['options']): void; }