• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2023 gRPC authors.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 //
16 // Automatically generated by tools/codegen/core/gen_config_vars.py
17 //
18 
19 #include "src/core/config/config_vars.h"
20 
21 #include <grpc/support/port_platform.h>
22 
23 #include "absl/flags/flag.h"
24 #include "absl/strings/escaping.h"
25 #include "src/core/config/load_config.h"
26 
27 #ifndef GPR_DEFAULT_LOG_VERBOSITY_STRING
28 #define GPR_DEFAULT_LOG_VERBOSITY_STRING ""
29 #endif  // !GPR_DEFAULT_LOG_VERBOSITY_STRING
30 
31 #ifdef GRPC_ENABLE_FORK_SUPPORT
32 #define GRPC_ENABLE_FORK_SUPPORT_DEFAULT true
33 #else
34 #define GRPC_ENABLE_FORK_SUPPORT_DEFAULT false
35 #endif  // GRPC_ENABLE_FORK_SUPPORT
36 
37 ABSL_FLAG(std::vector<std::string>, grpc_experiments, {},
38           "A comma separated list of currently active experiments. Experiments "
39           "may be prefixed with a '-' to disable them.");
40 ABSL_FLAG(absl::optional<int32_t>, grpc_client_channel_backup_poll_interval_ms,
41           {},
42           "Declares the interval in ms between two backup polls on client "
43           "channels. These polls are run in the timer thread so that gRPC can "
44           "process connection failures while there is no active polling "
45           "thread. They help reconnect disconnected client channels (mostly "
46           "due to idleness), so that the next RPC on this channel won't fail. "
47           "Set to 0 to turn off the backup polls.");
48 ABSL_FLAG(absl::optional<std::string>, grpc_dns_resolver, {},
49           "Declares which DNS resolver to use. The default is ares if gRPC is "
50           "built with c-ares support. Otherwise, the value of this environment "
51           "variable is ignored.");
52 ABSL_FLAG(std::vector<std::string>, grpc_trace, {},
53           "A comma separated list of tracers that provide additional insight "
54           "into how gRPC C core is processing requests via debug logs.");
55 ABSL_FLAG(absl::optional<std::string>, grpc_verbosity, {},
56           "Logging verbosity.");
57 ABSL_FLAG(absl::optional<bool>, grpc_enable_fork_support, {},
58           "Enable fork support");
59 ABSL_FLAG(absl::optional<std::string>, grpc_poll_strategy, {},
60           "Declares which polling engines to try when starting gRPC. This is a "
61           "comma-separated list of engines, which are tried in priority order "
62           "first -> last.");
63 ABSL_FLAG(absl::optional<bool>, grpc_abort_on_leaks, {},
64           "A debugging aid to cause a call to abort() when gRPC objects are "
65           "leaked past grpc_shutdown()");
66 ABSL_FLAG(absl::optional<std::string>, grpc_system_ssl_roots_dir, {},
67           "Custom directory to SSL Roots");
68 ABSL_FLAG(absl::optional<std::string>, grpc_default_ssl_roots_file_path, {},
69           "Path to the default SSL roots file.");
70 ABSL_FLAG(absl::optional<bool>, grpc_not_use_system_ssl_roots, {},
71           "Disable loading system root certificates.");
72 ABSL_FLAG(absl::optional<std::string>, grpc_ssl_cipher_suites, {},
73           "A colon separated list of cipher suites to use with OpenSSL");
74 ABSL_FLAG(absl::optional<bool>, grpc_cpp_experimental_disable_reflection, {},
75           "EXPERIMENTAL. Only respected when there is a dependency on "
76           ":grpc++_reflection. If true, no reflection server will be "
77           "automatically added.");
78 
79 namespace grpc_core {
80 
ConfigVars(const Overrides & overrides)81 ConfigVars::ConfigVars(const Overrides& overrides)
82     : client_channel_backup_poll_interval_ms_(
83           LoadConfig(FLAGS_grpc_client_channel_backup_poll_interval_ms,
84                      "GRPC_CLIENT_CHANNEL_BACKUP_POLL_INTERVAL_MS",
85                      overrides.client_channel_backup_poll_interval_ms, 5000)),
86       enable_fork_support_(LoadConfig(
87           FLAGS_grpc_enable_fork_support, "GRPC_ENABLE_FORK_SUPPORT",
88           overrides.enable_fork_support, GRPC_ENABLE_FORK_SUPPORT_DEFAULT)),
89       abort_on_leaks_(LoadConfig(FLAGS_grpc_abort_on_leaks,
90                                  "GRPC_ABORT_ON_LEAKS",
91                                  overrides.abort_on_leaks, false)),
92       not_use_system_ssl_roots_(LoadConfig(
93           FLAGS_grpc_not_use_system_ssl_roots, "GRPC_NOT_USE_SYSTEM_SSL_ROOTS",
94           overrides.not_use_system_ssl_roots, false)),
95       cpp_experimental_disable_reflection_(
96           LoadConfig(FLAGS_grpc_cpp_experimental_disable_reflection,
97                      "GRPC_CPP_EXPERIMENTAL_DISABLE_REFLECTION",
98                      overrides.cpp_experimental_disable_reflection, false)),
99       dns_resolver_(LoadConfig(FLAGS_grpc_dns_resolver, "GRPC_DNS_RESOLVER",
100                                overrides.dns_resolver, "")),
101       verbosity_(LoadConfig(FLAGS_grpc_verbosity, "GRPC_VERBOSITY",
102                             overrides.verbosity,
103                             GPR_DEFAULT_LOG_VERBOSITY_STRING)),
104       poll_strategy_(LoadConfig(FLAGS_grpc_poll_strategy, "GRPC_POLL_STRATEGY",
105                                 overrides.poll_strategy, "all")),
106       ssl_cipher_suites_(LoadConfig(
107           FLAGS_grpc_ssl_cipher_suites, "GRPC_SSL_CIPHER_SUITES",
108           overrides.ssl_cipher_suites,
109           "TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_"
110           "SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:"
111           "ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384")),
112       experiments_(LoadConfig(FLAGS_grpc_experiments, "GRPC_EXPERIMENTS",
113                               overrides.experiments, "")),
114       trace_(LoadConfig(FLAGS_grpc_trace, "GRPC_TRACE", overrides.trace, "")),
115       override_system_ssl_roots_dir_(overrides.system_ssl_roots_dir),
116       override_default_ssl_roots_file_path_(
117           overrides.default_ssl_roots_file_path) {}
118 
SystemSslRootsDir() const119 std::string ConfigVars::SystemSslRootsDir() const {
120   return LoadConfig(FLAGS_grpc_system_ssl_roots_dir,
121                     "GRPC_SYSTEM_SSL_ROOTS_DIR", override_system_ssl_roots_dir_,
122                     "");
123 }
124 
DefaultSslRootsFilePath() const125 std::string ConfigVars::DefaultSslRootsFilePath() const {
126   return LoadConfig(FLAGS_grpc_default_ssl_roots_file_path,
127                     "GRPC_DEFAULT_SSL_ROOTS_FILE_PATH",
128                     override_default_ssl_roots_file_path_, "");
129 }
130 
ToString() const131 std::string ConfigVars::ToString() const {
132   return absl::StrCat(
133       "experiments: ", "\"", absl::CEscape(Experiments()), "\"",
134       ", client_channel_backup_poll_interval_ms: ",
135       ClientChannelBackupPollIntervalMs(), ", dns_resolver: ", "\"",
136       absl::CEscape(DnsResolver()), "\"", ", trace: ", "\"",
137       absl::CEscape(Trace()), "\"", ", verbosity: ", "\"",
138       absl::CEscape(Verbosity()), "\"",
139       ", enable_fork_support: ", EnableForkSupport() ? "true" : "false",
140       ", poll_strategy: ", "\"", absl::CEscape(PollStrategy()), "\"",
141       ", abort_on_leaks: ", AbortOnLeaks() ? "true" : "false",
142       ", system_ssl_roots_dir: ", "\"", absl::CEscape(SystemSslRootsDir()),
143       "\"", ", default_ssl_roots_file_path: ", "\"",
144       absl::CEscape(DefaultSslRootsFilePath()), "\"",
145       ", not_use_system_ssl_roots: ", NotUseSystemSslRoots() ? "true" : "false",
146       ", ssl_cipher_suites: ", "\"", absl::CEscape(SslCipherSuites()), "\"",
147       ", cpp_experimental_disable_reflection: ",
148       CppExperimentalDisableReflection() ? "true" : "false");
149 }
150 
151 }  // namespace grpc_core
152