(
config: ConsulOptions,
clientName: string
)
| 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) { |
no test coverage detected