import { Rowan, Processor } from "rowan"; import { Wire } from "@viae/core"; import { Message } from './message'; import { Context, ContextConstructor } from "./context"; import { Log } from "./log"; import { IVia, SendOptions, CallOptions } from "./_via"; /** * Via * Wraps a wire connection and processes inbound and outbound messages */ export declare class Via extends Rowan implements IVia { private _ev; private _wire; private _uuid; private _log; private _timeout; private _interceptor; private _encoder; private _before; private CtxCtor; readonly out: Rowan; get wire(): Wire; static Log: import("pino").Logger; constructor(opts: { wire: Wire; Ctx?: ContextConstructor; uuid?: () => string; log?: Log; timeout?: number; }); get log(): Log; get ready(): Promise; private _onMessage; /** * Fire and Forget - Add a message to the outgoing pipeline **/ send(msg: Partial, opts?: SendOptions): Promise; /** * Send a request message, add an one-off interceptor for the response. Returns promise to first response. * @param msg * @param opts */ request(method: string, path: string, data?: any, opts?: SendOptions): Promise>; /** * simplified request/response - this will deserialise the response data and return it if successful. * throws an error if the result status is not OK. **/ call(opts: CallOptions): Promise; /** * intercept an id-specific message * @param id message id to intercept * @param handlers processors to call on interception */ intercept(id: string, handlers: Processor[]): () => void; /** * processors to use before any in-built (inbound)processing * @param processor */ before(processor: Processor): this; createId(): string; on(event: "close", cb: () => void): any; on(event: "open", cb: () => void): any; on(event: "error", cb: (err: Error, ctx: C) => void): any; off(event: "close", cb: () => void): any; off(event: "open", cb: () => void): any; off(event: "error", cb: (err: Error, ctx: C) => void): any; }