blob: 4006426b442f382b7836f25c6b1e1c96556288db (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
import { Status } from './constants';
import { Duration } from './duration';
import { LoadBalancingConfig } from './load-balancer';
export interface MethodConfigName {
service?: string;
method?: string;
}
export interface RetryPolicy {
maxAttempts: number;
initialBackoff: string;
maxBackoff: string;
backoffMultiplier: number;
retryableStatusCodes: (Status | string)[];
}
export interface HedgingPolicy {
maxAttempts: number;
hedgingDelay?: string;
nonFatalStatusCodes?: (Status | string)[];
}
export interface MethodConfig {
name: MethodConfigName[];
waitForReady?: boolean;
timeout?: Duration;
maxRequestBytes?: number;
maxResponseBytes?: number;
retryPolicy?: RetryPolicy;
hedgingPolicy?: HedgingPolicy;
}
export interface RetryThrottling {
maxTokens: number;
tokenRatio: number;
}
export interface ServiceConfig {
loadBalancingPolicy?: string;
loadBalancingConfig: LoadBalancingConfig[];
methodConfig: MethodConfig[];
retryThrottling?: RetryThrottling;
}
export interface ServiceConfigCanaryConfig {
clientLanguage?: string[];
percentage?: number;
clientHostname?: string[];
serviceConfig: ServiceConfig;
}
export declare function validateRetryThrottling(obj: any): RetryThrottling;
export declare function validateServiceConfig(obj: any): ServiceConfig;
/**
* Find the "grpc_config" record among the TXT records, parse its value as JSON, validate its contents,
* and select a service config with selection fields that all match this client. Most of these steps
* can fail with an error; the caller must handle any errors thrown this way.
* @param txtRecord The TXT record array that is output from a successful call to dns.resolveTxt
* @param percentage A number chosen from the range [0, 100) that is used to select which config to use
* @return The service configuration to use, given the percentage value, or null if the service config
* data has a valid format but none of the options match the current client.
*/
export declare function extractAndSelectServiceConfig(txtRecord: string[][], percentage: number): ServiceConfig | null;
|