UNPKG

1.97 kBTypeScriptView Raw
1export interface TcpSubchannelAddress {
2 port: number;
3 host: string;
4}
5export interface IpcSubchannelAddress {
6 path: string;
7}
8/**
9 * This represents a single backend address to connect to. This interface is a
10 * subset of net.SocketConnectOpts, i.e. the options described at
11 * https://nodejs.org/api/net.html#net_socket_connect_options_connectlistener.
12 * Those are in turn a subset of the options that can be passed to http2.connect.
13 */
14export type SubchannelAddress = TcpSubchannelAddress | IpcSubchannelAddress;
15export declare function isTcpSubchannelAddress(address: SubchannelAddress): address is TcpSubchannelAddress;
16export declare function subchannelAddressEqual(address1?: SubchannelAddress, address2?: SubchannelAddress): boolean;
17export declare function subchannelAddressToString(address: SubchannelAddress): string;
18export declare function stringToSubchannelAddress(addressString: string, port?: number): SubchannelAddress;
19export interface Endpoint {
20 addresses: SubchannelAddress[];
21}
22export declare function endpointEqual(endpoint1: Endpoint, endpoint2: Endpoint): boolean;
23export declare function endpointToString(endpoint: Endpoint): string;
24export declare function endpointHasAddress(endpoint: Endpoint, expectedAddress: SubchannelAddress): boolean;
25export declare class EndpointMap<ValueType> {
26 private map;
27 get size(): number;
28 getForSubchannelAddress(address: SubchannelAddress): ValueType | undefined;
29 /**
30 * Delete any entries in this map with keys that are not in endpoints
31 * @param endpoints
32 */
33 deleteMissing(endpoints: Endpoint[]): ValueType[];
34 get(endpoint: Endpoint): ValueType | undefined;
35 set(endpoint: Endpoint, mapEntry: ValueType): void;
36 delete(endpoint: Endpoint): void;
37 has(endpoint: Endpoint): boolean;
38 clear(): void;
39 keys(): IterableIterator<Endpoint>;
40 values(): IterableIterator<ValueType>;
41 entries(): IterableIterator<[Endpoint, ValueType]>;
42}