1 | import { MethodConfig, ServiceConfig } from './service-config';
|
2 | import { StatusObject } from './call-stream';
|
3 | import { SubchannelAddress } from './subchannel';
|
4 | import { GrpcUri } from './uri-parser';
|
5 | import { ChannelOptions } from './channel-options';
|
6 | import { Metadata } from './metadata';
|
7 | import { Status } from './constants';
|
8 | export interface CallConfig {
|
9 | methodConfig: MethodConfig;
|
10 | onCommitted?: () => void;
|
11 | pickInformation: {
|
12 | [key: string]: string;
|
13 | };
|
14 | status: Status;
|
15 | }
|
16 | /**
|
17 | * Selects a configuration for a method given the name and metadata. Defined in
|
18 | * https://github.com/grpc/proposal/blob/master/A31-xds-timeout-support-and-config-selector.md#new-functionality-in-grpc
|
19 | */
|
20 | export interface ConfigSelector {
|
21 | (methodName: string, metadata: Metadata): CallConfig;
|
22 | }
|
23 | /**
|
24 | * A listener object passed to the resolver's constructor that provides name
|
25 | * resolution updates back to the resolver's owner.
|
26 | */
|
27 | export interface ResolverListener {
|
28 | /**
|
29 | * Called whenever the resolver has new name resolution results to report
|
30 | * @param addressList The new list of backend addresses
|
31 | * @param serviceConfig The new service configuration corresponding to the
|
32 | * `addressList`. Will be `null` if no service configuration was
|
33 | * retrieved or if the service configuration was invalid
|
34 | * @param serviceConfigError If non-`null`, indicates that the retrieved
|
35 | * service configuration was invalid
|
36 | */
|
37 | onSuccessfulResolution(addressList: SubchannelAddress[], serviceConfig: ServiceConfig | null, serviceConfigError: StatusObject | null, configSelector: ConfigSelector | null, attributes: {
|
38 | [key: string]: unknown;
|
39 | }): void;
|
40 | /**
|
41 | * Called whenever a name resolution attempt fails.
|
42 | * @param error Describes how resolution failed
|
43 | */
|
44 | onError(error: StatusObject): void;
|
45 | }
|
46 | /**
|
47 | * A resolver class that handles one or more of the name syntax schemes defined
|
48 | * in the [gRPC Name Resolution document](https://github.com/grpc/grpc/blob/master/doc/naming.md)
|
49 | */
|
50 | export interface Resolver {
|
51 | /**
|
52 | * Indicates that the caller wants new name resolution data. Calling this
|
53 | * function may eventually result in calling one of the `ResolverListener`
|
54 | * functions, but that is not guaranteed. Those functions will never be
|
55 | * called synchronously with the constructor or updateResolution.
|
56 | */
|
57 | updateResolution(): void;
|
58 | /**
|
59 | * Destroy the resolver. Should be called when the owning channel shuts down.
|
60 | */
|
61 | destroy(): void;
|
62 | }
|
63 | export interface ResolverConstructor {
|
64 | new (target: GrpcUri, listener: ResolverListener, channelOptions: ChannelOptions): Resolver;
|
65 | /**
|
66 | * Get the default authority for a target. This loosely corresponds to that
|
67 | * target's hostname. Throws an error if this resolver class cannot parse the
|
68 | * `target`.
|
69 | * @param target
|
70 | */
|
71 | getDefaultAuthority(target: GrpcUri): string;
|
72 | }
|
73 | /**
|
74 | * Register a resolver class to handle target names prefixed with the `prefix`
|
75 | * string. This prefix should correspond to a URI scheme name listed in the
|
76 | * [gRPC Name Resolution document](https://github.com/grpc/grpc/blob/master/doc/naming.md)
|
77 | * @param prefix
|
78 | * @param resolverClass
|
79 | */
|
80 | export declare function registerResolver(scheme: string, resolverClass: ResolverConstructor): void;
|
81 | /**
|
82 | * Register a default resolver to handle target names that do not start with
|
83 | * any registered prefix.
|
84 | * @param resolverClass
|
85 | */
|
86 | export declare function registerDefaultScheme(scheme: string): void;
|
87 | /**
|
88 | * Create a name resolver for the specified target, if possible. Throws an
|
89 | * error if no such name resolver can be created.
|
90 | * @param target
|
91 | * @param listener
|
92 | */
|
93 | export declare function createResolver(target: GrpcUri, listener: ResolverListener, options: ChannelOptions): Resolver;
|
94 | /**
|
95 | * Get the default authority for the specified target, if possible. Throws an
|
96 | * error if no registered name resolver can parse that target string.
|
97 | * @param target
|
98 | */
|
99 | export declare function getDefaultAuthority(target: GrpcUri): string;
|
100 | export declare function mapUriDefaultScheme(target: GrpcUri): GrpcUri | null;
|
101 | export declare function registerAll(): void;
|