@betit/orion-node-sdk
Version:
SDK for orion
61 lines (60 loc) • 1.71 kB
TypeScript
import { Request } from '../request/request';
export interface Codec {
encoding?: string;
contentType?: string;
encode(data: any): any;
decode(data: any): any;
}
export interface Transport {
listen(callback: Function): any;
publish(topic: string, message: any): any;
subscribe(topic: string, group: string, callback: Function): any;
handle(route: string, group: string, callback: Function): any;
request(route: string, payload: any, callback: Function, timeout: number): any;
close(): any;
onClose(callback: (...args: any[]) => void): any;
}
export interface Client {
emit(topic: string, message: any): any;
call(request: Request, callback: Function): any;
}
export interface Service {
emit(topic: string, message: any): any;
on(topic: string, callback: Function): any;
handle(method: string, callback: Function): any;
}
export interface Tracer {
trace(req: Request): Function;
}
export interface Logger {
createMessage(message: string): Message;
send(m: RawMessage): any;
}
export interface Message {
setId(id: string): Message;
setParams(params: any): Message;
setMap(params: any): Message;
setLevel(level: number): Message;
setLOC(err: Error): this;
setError(err: Error): this;
send(): any;
}
export interface RawMessage {
level: number;
timestamp: number;
params: any;
message: string;
host: string;
'x-trace-id': string;
}
export interface Options {
codec?: Codec;
tracer?: Tracer;
transport?: Transport;
logger?: Logger;
timeout?: number;
timeouts?: {};
service?: string;
enableStatusEndpoints?: boolean;
registerToWatchdog?: boolean;
}