|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import { Resolver, ResolverListener, registerResolver } from './resolver'; |
|
import { SubchannelAddress } from './subchannel-address'; |
|
import { GrpcUri } from './uri-parser'; |
|
import { ChannelOptions } from './channel-options'; |
|
|
|
class UdsResolver implements Resolver { |
|
private addresses: SubchannelAddress[] = []; |
|
constructor( |
|
target: GrpcUri, |
|
private listener: ResolverListener, |
|
channelOptions: ChannelOptions |
|
) { |
|
let path: string; |
|
if (target.authority === '') { |
|
path = '/' + target.path; |
|
} else { |
|
path = target.path; |
|
} |
|
this.addresses = [{ path }]; |
|
} |
|
updateResolution(): void { |
|
process.nextTick( |
|
this.listener.onSuccessfulResolution, |
|
this.addresses, |
|
null, |
|
null, |
|
null, |
|
{} |
|
); |
|
} |
|
|
|
destroy() { |
|
|
|
} |
|
|
|
static getDefaultAuthority(target: GrpcUri): string { |
|
return 'localhost'; |
|
} |
|
} |
|
|
|
export function setup() { |
|
registerResolver('unix', UdsResolver); |
|
} |
|
|