1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | import { Resolver, ResolverListener, registerResolver } from './resolver';
|
18 | import { SubchannelAddress } from './subchannel-address';
|
19 | import { GrpcUri } from './uri-parser';
|
20 | import { ChannelOptions } from './channel-options';
|
21 |
|
22 | class UdsResolver implements Resolver {
|
23 | private addresses: SubchannelAddress[] = [];
|
24 | constructor(
|
25 | target: GrpcUri,
|
26 | private listener: ResolverListener,
|
27 | channelOptions: ChannelOptions
|
28 | ) {
|
29 | let path: string;
|
30 | if (target.authority === '') {
|
31 | path = '/' + target.path;
|
32 | } else {
|
33 | path = target.path;
|
34 | }
|
35 | this.addresses = [{ path }];
|
36 | }
|
37 | updateResolution(): void {
|
38 | process.nextTick(
|
39 | this.listener.onSuccessfulResolution,
|
40 | this.addresses,
|
41 | null,
|
42 | null,
|
43 | null,
|
44 | {}
|
45 | );
|
46 | }
|
47 |
|
48 | destroy() {
|
49 |
|
50 | }
|
51 |
|
52 | static getDefaultAuthority(target: GrpcUri): string {
|
53 | return 'localhost';
|
54 | }
|
55 | }
|
56 |
|
57 | export function setup() {
|
58 | registerResolver('unix', UdsResolver);
|
59 | }
|