node-universe
Version:
基于 Nodejs 环境的一款微服务框架,原理来自于宇宙中的恒星,行星,卫星等系统。
81 lines (80 loc) • 3.09 kB
TypeScript
import { LoggerInstance } from '../../typings/logger';
import Star from '../star';
import { GenericObject } from '../../typings';
import Node from './node';
import NodeCatalog from './catalogs/node';
import { Discoverer } from '../../typings/registry/discoverers';
import BaseStrategy from '../strategies/base';
import EventCatalog from './catalogs/event';
import ActionCatalog from './catalogs/action';
import ServiceCatalog from './catalogs/service';
import Service from '../star/service';
import ServiceItem from './service-item';
import ActionEndpoint from './endpoint/action';
import { MetricRegistry } from '../metrics';
export default class Registry {
star: Star;
logger: LoggerInstance;
metrics: MetricRegistry | null;
StrategyFactory: typeof BaseStrategy;
discoverer: Discoverer;
options: GenericObject;
localNodeInfoInvalidated: boolean | string;
nodes: NodeCatalog;
services: ServiceCatalog;
actions: ActionCatalog;
events: EventCatalog;
constructor(star: Star);
init(star: Star): void;
stop(): Promise<void>;
private registerUniverseMetrics;
private updateMetrics;
registerActions(node: Node, service: ServiceItem, actions: any): void;
registerEvents(node: Node, service: ServiceItem, events: any): void;
registerLocalService(service: ServiceItem): void;
registerServices(node: Node, serviceList: Array<Service>): void;
unregisterAction(node: Node, actionName: string): void;
unregisterEvent(node: Node, eventName: string): void;
unregisterService(fullName: string, nodeID?: string): void;
unregisterServicesByNode(nodeID: string): void;
checkActionVisibility(action: any, node: Node): boolean;
processNodeInfo(payload: any): Node;
regenerateLocalRawInfo(incSeq?: boolean, isStopping?: boolean): any;
getLocalNodeInfo(force?: boolean): any;
getNodeInfo(nodeID: string): any;
createPrivateActionEndpoint(action: any): ActionEndpoint | undefined;
hasService(fullName: string, nodeID?: string): boolean;
getActionEndpoints(actionName: string): import("./endpoint/list").default | undefined;
getActionEndpointByNodeId(actionName: string, nodeID: string): import("./endpoint/item").default | null | undefined;
getNodeList(options: {
onlyAvaiable: boolean;
withServices: boolean;
}): Omit<Node, "services" | "rawInfo">[];
getServiceList(options: {
onlyLocal: boolean;
onlyAvaliable: boolean;
skipInterval: boolean;
withActions: boolean;
withEvents: boolean;
grouping: boolean;
}): any[];
getActionList(options: {
onlyLocal: boolean;
onlyAvaliable: boolean;
skipInterval: boolean;
withEndpoints: boolean;
}): any[];
getEventList(options: {
onlyLocal: boolean;
onlyAvaliable: boolean;
skipInterval: boolean;
withEndpoints: boolean;
}): any[];
getNodeRawList(): any[];
printLogger(name: string, results: Array<{
key?: string;
value?: any;
}>): void;
}
>): void;
}