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-node.max_session_memory'?: number;
|
48 |
|
49 | [key: string]: any;
|
50 | }
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 | export const recognizedOptions = {
|
57 | 'grpc.ssl_target_name_override': true,
|
58 | 'grpc.primary_user_agent': true,
|
59 | 'grpc.secondary_user_agent': true,
|
60 | 'grpc.default_authority': true,
|
61 | 'grpc.keepalive_time_ms': true,
|
62 | 'grpc.keepalive_timeout_ms': true,
|
63 | 'grpc.keepalive_permit_without_calls': true,
|
64 | 'grpc.service_config': true,
|
65 | 'grpc.max_concurrent_streams': true,
|
66 | 'grpc.initial_reconnect_backoff_ms': true,
|
67 | 'grpc.max_reconnect_backoff_ms': true,
|
68 | 'grpc.use_local_subchannel_pool': true,
|
69 | 'grpc.max_send_message_length': true,
|
70 | 'grpc.max_receive_message_length': true,
|
71 | 'grpc.enable_http_proxy': true,
|
72 | 'grpc.enable_channelz': true,
|
73 | 'grpc.dns_min_time_between_resolutions_ms': true,
|
74 | 'grpc-node.max_session_memory': true,
|
75 | };
|
76 |
|
77 | export function channelOptionsEqual(
|
78 | options1: ChannelOptions,
|
79 | options2: ChannelOptions
|
80 | ) {
|
81 | const keys1 = Object.keys(options1).sort();
|
82 | const keys2 = Object.keys(options2).sort();
|
83 | if (keys1.length !== keys2.length) {
|
84 | return false;
|
85 | }
|
86 | for (let i = 0; i < keys1.length; i += 1) {
|
87 | if (keys1[i] !== keys2[i]) {
|
88 | return false;
|
89 | }
|
90 | if (options1[keys1[i]] !== options2[keys2[i]]) {
|
91 | return false;
|
92 | }
|
93 | }
|
94 | return true;
|
95 | }
|