node-universe
Version:
基于 Nodejs 环境的一款微服务框架,原理来自于宇宙中的恒星,行星,卫星等系统。
57 lines (56 loc) • 2.23 kB
TypeScript
import { GenericObject } from '../../typings';
import Endpoint from '../registry/endpoint/item';
import Star from '../star';
import { ActionSchema, CallingOptions } from '../../typings/context';
import Service from '../star/service';
import { EventSchema } from '../../typings/context/event';
import { MCallCallingOptions, StarMCallActionParams } from '../../typings/star';
import util from 'util';
import Span from '../tracing/span';
export default class Context {
id: string;
star: Star;
nodeID: string | null;
endpoint: Endpoint | null;
action: ActionSchema | null;
service: Service | null;
event: EventSchema | null;
eventName: string | null;
eventType: string | null;
eventGroups: string[] | null;
options: CallingOptions;
parentID: string | null;
caller: string | null;
tracing: boolean | null;
span: Span | null;
_spanStack: Span[];
needAck: boolean | null;
ackID: string | null;
locals: GenericObject;
level: number;
params: any;
meta: GenericObject;
requestID: string | null;
cachedResult: boolean;
starHrTime: any;
constructor(star: Star, endpoint?: Endpoint);
static create(star: Star, endpoint: Endpoint, params?: GenericObject, options?: GenericObject): Context;
copy(endpoint?: Endpoint): Context;
setParams(newParams: GenericObject, cloning?: boolean): void;
setEndpoint(endpoint: Endpoint): void;
call(actionName: string, params?: GenericObject, options?: GenericObject): Promise<any>;
mcall(def: Array<StarMCallActionParams> | Record<string, StarMCallActionParams>, opts?: MCallCallingOptions): Promise<any[] | GenericObject>;
emit(eventName: string, data?: any, options?: GenericObject): Promise<any[]> | Promise<void> | undefined;
broadcast(eventName: string, data?: any, options?: GenericObject): Promise<any[]> | undefined;
setContextEventData(options: {
eventName?: string;
eventType?: string;
eventGroups?: string[];
}): void;
startSpan(name: string, opts?: GenericObject): any;
finishSpan(span: Span, time?: number): void;
toJSON(): Partial<this>;
[util.inspect.custom](depth: number, options: any): any;
}
s: any): any;
}