UNPKG

1.57 kBTypeScriptView Raw
1import { LoadBalancingConfig } from './load-balancer';
2export interface MethodConfigName {
3 service: string;
4 method?: string;
5}
6export interface Duration {
7 seconds: number;
8 nanos: number;
9}
10export interface MethodConfig {
11 name: MethodConfigName[];
12 waitForReady?: boolean;
13 timeout?: Duration;
14 maxRequestBytes?: number;
15 maxResponseBytes?: number;
16}
17export interface ServiceConfig {
18 loadBalancingPolicy?: string;
19 loadBalancingConfig: LoadBalancingConfig[];
20 methodConfig: MethodConfig[];
21}
22export interface ServiceConfigCanaryConfig {
23 clientLanguage?: string[];
24 percentage?: number;
25 clientHostname?: string[];
26 serviceConfig: ServiceConfig;
27}
28export declare function validateServiceConfig(obj: any): ServiceConfig;
29/**
30 * Find the "grpc_config" record among the TXT records, parse its value as JSON, validate its contents,
31 * and select a service config with selection fields that all match this client. Most of these steps
32 * can fail with an error; the caller must handle any errors thrown this way.
33 * @param txtRecord The TXT record array that is output from a successful call to dns.resolveTxt
34 * @param percentage A number chosen from the range [0, 100) that is used to select which config to use
35 * @return The service configuration to use, given the percentage value, or null if the service config
36 * data has a valid format but none of the options match the current client.
37 */
38export declare function extractAndSelectServiceConfig(txtRecord: string[][], percentage: number): ServiceConfig | null;