UNPKG

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