1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 | import { CompressionAlgorithms } from './compression-algorithms';
|
19 |
|
20 |
|
21 |
|
22 |
|
23 | export interface ChannelOptions {
|
24 | 'grpc.ssl_target_name_override'?: string;
|
25 | 'grpc.primary_user_agent'?: string;
|
26 | 'grpc.secondary_user_agent'?: string;
|
27 | 'grpc.default_authority'?: string;
|
28 | 'grpc.keepalive_time_ms'?: number;
|
29 | 'grpc.keepalive_timeout_ms'?: number;
|
30 | 'grpc.keepalive_permit_without_calls'?: number;
|
31 | 'grpc.service_config'?: string;
|
32 | 'grpc.max_concurrent_streams'?: number;
|
33 | 'grpc.initial_reconnect_backoff_ms'?: number;
|
34 | 'grpc.max_reconnect_backoff_ms'?: number;
|
35 | 'grpc.use_local_subchannel_pool'?: number;
|
36 | 'grpc.max_send_message_length'?: number;
|
37 | 'grpc.max_receive_message_length'?: number;
|
38 | 'grpc.enable_http_proxy'?: number;
|
39 | |
40 |
|
41 |
|
42 | 'grpc.http_connect_target'?: string;
|
43 | 'grpc.http_connect_creds'?: string;
|
44 | 'grpc.default_compression_algorithm'?: CompressionAlgorithms;
|
45 | 'grpc.enable_channelz'?: number;
|
46 | 'grpc.dns_min_time_between_resolutions_ms'?: number;
|
47 | 'grpc.enable_retries'?: number;
|
48 | 'grpc.per_rpc_retry_buffer_size'?: number;
|
49 | |
50 |
|
51 |
|
52 |
|
53 |
|
54 | 'grpc.retry_buffer_size'?: number;
|
55 | 'grpc.max_connection_age_ms'?: number;
|
56 | 'grpc.max_connection_age_grace_ms'?: number;
|
57 | 'grpc.max_connection_idle_ms'?: number;
|
58 | 'grpc-node.max_session_memory'?: number;
|
59 | 'grpc.service_config_disable_resolution'?: number;
|
60 | 'grpc.client_idle_timeout_ms'?: number;
|
61 | |
62 |
|
63 |
|
64 | 'grpc-node.tls_enable_trace'?: number;
|
65 | 'grpc.lb.ring_hash.ring_size_cap'?: number;
|
66 |
|
67 | [key: string]: any;
|
68 | }
|
69 |
|
70 |
|
71 |
|
72 |
|
73 |
|
74 | export const recognizedOptions = {
|
75 | 'grpc.ssl_target_name_override': true,
|
76 | 'grpc.primary_user_agent': true,
|
77 | 'grpc.secondary_user_agent': true,
|
78 | 'grpc.default_authority': true,
|
79 | 'grpc.keepalive_time_ms': true,
|
80 | 'grpc.keepalive_timeout_ms': true,
|
81 | 'grpc.keepalive_permit_without_calls': true,
|
82 | 'grpc.service_config': true,
|
83 | 'grpc.max_concurrent_streams': true,
|
84 | 'grpc.initial_reconnect_backoff_ms': true,
|
85 | 'grpc.max_reconnect_backoff_ms': true,
|
86 | 'grpc.use_local_subchannel_pool': true,
|
87 | 'grpc.max_send_message_length': true,
|
88 | 'grpc.max_receive_message_length': true,
|
89 | 'grpc.enable_http_proxy': true,
|
90 | 'grpc.enable_channelz': true,
|
91 | 'grpc.dns_min_time_between_resolutions_ms': true,
|
92 | 'grpc.enable_retries': true,
|
93 | 'grpc.per_rpc_retry_buffer_size': true,
|
94 | 'grpc.retry_buffer_size': true,
|
95 | 'grpc.max_connection_age_ms': true,
|
96 | 'grpc.max_connection_age_grace_ms': true,
|
97 | 'grpc-node.max_session_memory': true,
|
98 | 'grpc.service_config_disable_resolution': true,
|
99 | 'grpc.client_idle_timeout_ms': true,
|
100 | 'grpc-node.tls_enable_trace': true,
|
101 | 'grpc.lb.ring_hash.ring_size_cap': true,
|
102 | };
|
103 |
|
104 | export function channelOptionsEqual(
|
105 | options1: ChannelOptions,
|
106 | options2: ChannelOptions
|
107 | ) {
|
108 | const keys1 = Object.keys(options1).sort();
|
109 | const keys2 = Object.keys(options2).sort();
|
110 | if (keys1.length !== keys2.length) {
|
111 | return false;
|
112 | }
|
113 | for (let i = 0; i < keys1.length; i += 1) {
|
114 | if (keys1[i] !== keys2[i]) {
|
115 | return false;
|
116 | }
|
117 | if (options1[keys1[i]] !== options2[keys2[i]]) {
|
118 | return false;
|
119 | }
|
120 | }
|
121 | return true;
|
122 | }
|