UNPKG

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