MCPcopy
hub / github.com/midwayjs/midway / createClient

Method createClient

packages/consul/src/manager.ts:44–64  ·  view source on GitHub ↗
(
    config: ConsulOptions,
    clientName: string
  )

Source from the content-addressed store, hash-verified

42 traceService: MidwayTraceService;
43
44 async createClient(
45 config: ConsulOptions,
46 clientName: string
47 ): Promise<InstanceType<typeof Consul>> {
48 const { customClientClass, ...otherConfig } = config as any;
49 if (customClientClass) {
50 const client = new customClientClass(otherConfig);
51 this.bindTraceContext(client as any, clientName);
52 return client;
53 }
54
55 this.logger.info(
56 '[midway:consul] init %s at %s:%s',
57 clientName,
58 config.host,
59 config.port
60 );
61 const client = new Consul(config);
62 this.bindTraceContext(client as any, clientName);
63 return client;
64 }
65
66 protected bindTraceContext(client: any, clientName: string) {
67 if (!client || !this.traceService) {

Callers 2

Calls 2

bindTraceContextMethod · 0.95
infoMethod · 0.65

Tested by

no test coverage detected