From 4a053103cfe5f947507f67758e5736882e6bcdcd Mon Sep 17 00:00:00 2001 From: tanvi-jagtap Date: Wed, 13 Mar 2024 10:49:13 +0000 Subject: [PATCH] Formatting --- src/core/lib/config/config_vars.cc | 187 ++++++++++++++++++----------- src/core/lib/config/config_vars.h | 48 +++++--- test/core/util/fuzz_config_vars.cc | 17 +-- test/core/util/fuzz_config_vars.h | 15 +-- 4 files changed, 169 insertions(+), 98 deletions(-) diff --git a/src/core/lib/config/config_vars.cc b/src/core/lib/config/config_vars.cc index b7130f9dae6..c13c6c6d81e 100644 --- a/src/core/lib/config/config_vars.cc +++ b/src/core/lib/config/config_vars.cc @@ -1,26 +1,29 @@ // Copyright 2023 gRPC authors. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -// +// // Automatically generated by tools/codegen/core/gen_config_vars.py -// +// #include + #include "src/core/lib/config/config_vars.h" -#include "src/core/lib/config/load_config.h" -#include "absl/strings/escaping.h" + #include "absl/flags/flag.h" +#include "absl/strings/escaping.h" + +#include "src/core/lib/config/load_config.h" #ifndef GPR_DEFAULT_LOG_VERBOSITY_STRING #define GPR_DEFAULT_LOG_VERBOSITY_STRING "ERROR" @@ -32,74 +35,120 @@ #define GRPC_ENABLE_FORK_SUPPORT_DEFAULT false #endif // GRPC_ENABLE_FORK_SUPPORT -ABSL_FLAG(std::vector, grpc_experiments, {}, "A comma separated list of currently active experiments. Experiments may be prefixed with a '-' to disable them."); -ABSL_FLAG(absl::optional, grpc_client_channel_backup_poll_interval_ms, {}, "Declares the interval in ms between two backup polls on client channels. These polls are run in the timer thread so that gRPC can process connection failures while there is no active polling thread. They help reconnect disconnected client channels (mostly due to idleness), so that the next RPC on this channel won't fail. Set to 0 to turn off the backup polls."); -ABSL_FLAG(absl::optional, grpc_dns_resolver, {}, "Declares which DNS resolver to use. The default is ares if gRPC is built with c-ares support. Otherwise, the value of this environment variable is ignored."); -ABSL_FLAG(std::vector, grpc_trace, {}, "A comma separated list of tracers that provide additional insight into how gRPC C core is processing requests via debug logs."); -ABSL_FLAG(absl::optional, grpc_verbosity, {}, "Default gRPC logging verbosity"); -ABSL_FLAG(absl::optional, grpc_stacktrace_minloglevel, {}, "Messages logged at the same or higher level than this will print stacktrace"); -ABSL_FLAG(absl::optional, grpc_enable_fork_support, {}, "Enable fork support"); -ABSL_FLAG(absl::optional, grpc_poll_strategy, {}, "Declares which polling engines to try when starting gRPC. This is a comma-separated list of engines, which are tried in priority order first -> last."); -ABSL_FLAG(absl::optional, grpc_abort_on_leaks, {}, "A debugging aid to cause a call to abort() when gRPC objects are leaked past grpc_shutdown()"); -ABSL_FLAG(absl::optional, grpc_system_ssl_roots_dir, {}, "Custom directory to SSL Roots"); -ABSL_FLAG(absl::optional, grpc_default_ssl_roots_file_path, {}, "Path to the default SSL roots file."); -ABSL_FLAG(absl::optional, grpc_not_use_system_ssl_roots, {}, "Disable loading system root certificates."); -ABSL_FLAG(absl::optional, grpc_ssl_cipher_suites, {}, "A colon separated list of cipher suites to use with OpenSSL"); -ABSL_FLAG(absl::optional, grpc_absl_logging, {}, "Use absl logging from within gpr_log."); +ABSL_FLAG(std::vector, grpc_experiments, {}, + "A comma separated list of currently active experiments. Experiments " + "may be prefixed with a '-' to disable them."); +ABSL_FLAG(absl::optional, grpc_client_channel_backup_poll_interval_ms, + {}, + "Declares the interval in ms between two backup polls on client " + "channels. These polls are run in the timer thread so that gRPC can " + "process connection failures while there is no active polling " + "thread. They help reconnect disconnected client channels (mostly " + "due to idleness), so that the next RPC on this channel won't fail. " + "Set to 0 to turn off the backup polls."); +ABSL_FLAG(absl::optional, grpc_dns_resolver, {}, + "Declares which DNS resolver to use. The default is ares if gRPC is " + "built with c-ares support. Otherwise, the value of this environment " + "variable is ignored."); +ABSL_FLAG(std::vector, grpc_trace, {}, + "A comma separated list of tracers that provide additional insight " + "into how gRPC C core is processing requests via debug logs."); +ABSL_FLAG(absl::optional, grpc_verbosity, {}, + "Default gRPC logging verbosity"); +ABSL_FLAG(absl::optional, grpc_stacktrace_minloglevel, {}, + "Messages logged at the same or higher level than this will print " + "stacktrace"); +ABSL_FLAG(absl::optional, grpc_enable_fork_support, {}, + "Enable fork support"); +ABSL_FLAG(absl::optional, grpc_poll_strategy, {}, + "Declares which polling engines to try when starting gRPC. This is a " + "comma-separated list of engines, which are tried in priority order " + "first -> last."); +ABSL_FLAG(absl::optional, grpc_abort_on_leaks, {}, + "A debugging aid to cause a call to abort() when gRPC objects are " + "leaked past grpc_shutdown()"); +ABSL_FLAG(absl::optional, grpc_system_ssl_roots_dir, {}, + "Custom directory to SSL Roots"); +ABSL_FLAG(absl::optional, grpc_default_ssl_roots_file_path, {}, + "Path to the default SSL roots file."); +ABSL_FLAG(absl::optional, grpc_not_use_system_ssl_roots, {}, + "Disable loading system root certificates."); +ABSL_FLAG(absl::optional, grpc_ssl_cipher_suites, {}, + "A colon separated list of cipher suites to use with OpenSSL"); +ABSL_FLAG(absl::optional, grpc_absl_logging, {}, + "Use absl logging from within gpr_log."); namespace grpc_core { -ConfigVars::ConfigVars(const Overrides& overrides) : -client_channel_backup_poll_interval_ms_(LoadConfig(FLAGS_grpc_client_channel_backup_poll_interval_ms, "GRPC_CLIENT_CHANNEL_BACKUP_POLL_INTERVAL_MS", overrides.client_channel_backup_poll_interval_ms, 5000)),enable_fork_support_(LoadConfig(FLAGS_grpc_enable_fork_support, "GRPC_ENABLE_FORK_SUPPORT", overrides.enable_fork_support, GRPC_ENABLE_FORK_SUPPORT_DEFAULT)),abort_on_leaks_(LoadConfig(FLAGS_grpc_abort_on_leaks, "GRPC_ABORT_ON_LEAKS", overrides.abort_on_leaks, false)),not_use_system_ssl_roots_(LoadConfig(FLAGS_grpc_not_use_system_ssl_roots, "GRPC_NOT_USE_SYSTEM_SSL_ROOTS", overrides.not_use_system_ssl_roots, false)),absl_logging_(LoadConfig(FLAGS_grpc_absl_logging, "GRPC_ABSL_LOGGING", overrides.absl_logging, false)),dns_resolver_(LoadConfig(FLAGS_grpc_dns_resolver, "GRPC_DNS_RESOLVER", overrides.dns_resolver, "")),verbosity_(LoadConfig(FLAGS_grpc_verbosity, "GRPC_VERBOSITY", overrides.verbosity, GPR_DEFAULT_LOG_VERBOSITY_STRING)),stacktrace_minloglevel_(LoadConfig(FLAGS_grpc_stacktrace_minloglevel, "GRPC_STACKTRACE_MINLOGLEVEL", overrides.stacktrace_minloglevel, "")),poll_strategy_(LoadConfig(FLAGS_grpc_poll_strategy, "GRPC_POLL_STRATEGY", overrides.poll_strategy, "all")),ssl_cipher_suites_(LoadConfig(FLAGS_grpc_ssl_cipher_suites, "GRPC_SSL_CIPHER_SUITES", overrides.ssl_cipher_suites, "TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384")),experiments_(LoadConfig(FLAGS_grpc_experiments, "GRPC_EXPERIMENTS", overrides.experiments, "")),trace_(LoadConfig(FLAGS_grpc_trace, "GRPC_TRACE", overrides.trace, "")),override_system_ssl_roots_dir_(overrides.system_ssl_roots_dir),override_default_ssl_roots_file_path_(overrides.default_ssl_roots_file_path) -{} +ConfigVars::ConfigVars(const Overrides& overrides) + : client_channel_backup_poll_interval_ms_( + LoadConfig(FLAGS_grpc_client_channel_backup_poll_interval_ms, + "GRPC_CLIENT_CHANNEL_BACKUP_POLL_INTERVAL_MS", + overrides.client_channel_backup_poll_interval_ms, 5000)), + enable_fork_support_(LoadConfig( + FLAGS_grpc_enable_fork_support, "GRPC_ENABLE_FORK_SUPPORT", + overrides.enable_fork_support, GRPC_ENABLE_FORK_SUPPORT_DEFAULT)), + abort_on_leaks_(LoadConfig(FLAGS_grpc_abort_on_leaks, + "GRPC_ABORT_ON_LEAKS", + overrides.abort_on_leaks, false)), + not_use_system_ssl_roots_(LoadConfig( + FLAGS_grpc_not_use_system_ssl_roots, "GRPC_NOT_USE_SYSTEM_SSL_ROOTS", + overrides.not_use_system_ssl_roots, false)), + absl_logging_(LoadConfig(FLAGS_grpc_absl_logging, "GRPC_ABSL_LOGGING", + overrides.absl_logging, false)), + dns_resolver_(LoadConfig(FLAGS_grpc_dns_resolver, "GRPC_DNS_RESOLVER", + overrides.dns_resolver, "")), + verbosity_(LoadConfig(FLAGS_grpc_verbosity, "GRPC_VERBOSITY", + overrides.verbosity, + GPR_DEFAULT_LOG_VERBOSITY_STRING)), + stacktrace_minloglevel_(LoadConfig(FLAGS_grpc_stacktrace_minloglevel, + "GRPC_STACKTRACE_MINLOGLEVEL", + overrides.stacktrace_minloglevel, "")), + poll_strategy_(LoadConfig(FLAGS_grpc_poll_strategy, "GRPC_POLL_STRATEGY", + overrides.poll_strategy, "all")), + ssl_cipher_suites_(LoadConfig( + FLAGS_grpc_ssl_cipher_suites, "GRPC_SSL_CIPHER_SUITES", + overrides.ssl_cipher_suites, + "TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_" + "SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:" + "ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384")), + experiments_(LoadConfig(FLAGS_grpc_experiments, "GRPC_EXPERIMENTS", + overrides.experiments, "")), + trace_(LoadConfig(FLAGS_grpc_trace, "GRPC_TRACE", overrides.trace, "")), + override_system_ssl_roots_dir_(overrides.system_ssl_roots_dir), + override_default_ssl_roots_file_path_( + overrides.default_ssl_roots_file_path) {} -std::string ConfigVars::SystemSslRootsDir() const { return LoadConfig(FLAGS_grpc_system_ssl_roots_dir, "GRPC_SYSTEM_SSL_ROOTS_DIR", override_system_ssl_roots_dir_, ""); } +std::string ConfigVars::SystemSslRootsDir() const { + return LoadConfig(FLAGS_grpc_system_ssl_roots_dir, + "GRPC_SYSTEM_SSL_ROOTS_DIR", override_system_ssl_roots_dir_, + ""); +} -std::string ConfigVars::DefaultSslRootsFilePath() const { return LoadConfig(FLAGS_grpc_default_ssl_roots_file_path, "GRPC_DEFAULT_SSL_ROOTS_FILE_PATH", override_default_ssl_roots_file_path_, ""); } +std::string ConfigVars::DefaultSslRootsFilePath() const { + return LoadConfig(FLAGS_grpc_default_ssl_roots_file_path, + "GRPC_DEFAULT_SSL_ROOTS_FILE_PATH", + override_default_ssl_roots_file_path_, ""); +} std::string ConfigVars::ToString() const { return absl::StrCat( -"experiments: " -, "\"", absl::CEscape(Experiments()), "\"" -, -", client_channel_backup_poll_interval_ms: " -, ClientChannelBackupPollIntervalMs() -, -", dns_resolver: " -, "\"", absl::CEscape(DnsResolver()), "\"" -, -", trace: " -, "\"", absl::CEscape(Trace()), "\"" -, -", verbosity: " -, "\"", absl::CEscape(Verbosity()), "\"" -, -", stacktrace_minloglevel: " -, "\"", absl::CEscape(StacktraceMinloglevel()), "\"" -, -", enable_fork_support: " -, EnableForkSupport()?"true":"false" -, -", poll_strategy: " -, "\"", absl::CEscape(PollStrategy()), "\"" -, -", abort_on_leaks: " -, AbortOnLeaks()?"true":"false" -, -", system_ssl_roots_dir: " -, "\"", absl::CEscape(SystemSslRootsDir()), "\"" -, -", default_ssl_roots_file_path: " -, "\"", absl::CEscape(DefaultSslRootsFilePath()), "\"" -, -", not_use_system_ssl_roots: " -, NotUseSystemSslRoots()?"true":"false" -, -", ssl_cipher_suites: " -, "\"", absl::CEscape(SslCipherSuites()), "\"" -, -", absl_logging: " -, AbslLogging()?"true":"false" -);} - + "experiments: ", "\"", absl::CEscape(Experiments()), "\"", + ", client_channel_backup_poll_interval_ms: ", + ClientChannelBackupPollIntervalMs(), ", dns_resolver: ", "\"", + absl::CEscape(DnsResolver()), "\"", ", trace: ", "\"", + absl::CEscape(Trace()), "\"", ", verbosity: ", "\"", + absl::CEscape(Verbosity()), "\"", ", stacktrace_minloglevel: ", "\"", + absl::CEscape(StacktraceMinloglevel()), "\"", + ", enable_fork_support: ", EnableForkSupport() ? "true" : "false", + ", poll_strategy: ", "\"", absl::CEscape(PollStrategy()), "\"", + ", abort_on_leaks: ", AbortOnLeaks() ? "true" : "false", + ", system_ssl_roots_dir: ", "\"", absl::CEscape(SystemSslRootsDir()), + "\"", ", default_ssl_roots_file_path: ", "\"", + absl::CEscape(DefaultSslRootsFilePath()), "\"", + ", not_use_system_ssl_roots: ", NotUseSystemSslRoots() ? "true" : "false", + ", ssl_cipher_suites: ", "\"", absl::CEscape(SslCipherSuites()), "\"", + ", absl_logging: ", AbslLogging() ? "true" : "false"); } + +} // namespace grpc_core diff --git a/src/core/lib/config/config_vars.h b/src/core/lib/config/config_vars.h index d1c8c1379de..c252b2809dc 100644 --- a/src/core/lib/config/config_vars.h +++ b/src/core/lib/config/config_vars.h @@ -1,29 +1,31 @@ // Copyright 2023 gRPC authors. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -// +// // Automatically generated by tools/codegen/core/gen_config_vars.py -// +// #ifndef GRPC_SRC_CORE_LIB_CONFIG_CONFIG_VARS_H #define GRPC_SRC_CORE_LIB_CONFIG_CONFIG_VARS_H #include -#include -#include #include + +#include +#include + #include "absl/strings/string_view.h" #include "absl/types/optional.h" @@ -60,23 +62,38 @@ class GPR_DLL ConfigVars { // accessing the configuration. static void Reset(); std::string ToString() const; - // A comma separated list of currently active experiments. Experiments may be prefixed with a '-' to disable them. + // A comma separated list of currently active experiments. Experiments may be + // prefixed with a '-' to disable them. absl::string_view Experiments() const { return experiments_; } - // Declares the interval in ms between two backup polls on client channels. These polls are run in the timer thread so that gRPC can process connection failures while there is no active polling thread. They help reconnect disconnected client channels (mostly due to idleness), so that the next RPC on this channel won't fail. Set to 0 to turn off the backup polls. - int32_t ClientChannelBackupPollIntervalMs() const { return client_channel_backup_poll_interval_ms_; } - // Declares which DNS resolver to use. The default is ares if gRPC is built with c-ares support. Otherwise, the value of this environment variable is ignored. + // Declares the interval in ms between two backup polls on client channels. + // These polls are run in the timer thread so that gRPC can process connection + // failures while there is no active polling thread. They help reconnect + // disconnected client channels (mostly due to idleness), so that the next RPC + // on this channel won't fail. Set to 0 to turn off the backup polls. + int32_t ClientChannelBackupPollIntervalMs() const { + return client_channel_backup_poll_interval_ms_; + } + // Declares which DNS resolver to use. The default is ares if gRPC is built + // with c-ares support. Otherwise, the value of this environment variable is + // ignored. absl::string_view DnsResolver() const { return dns_resolver_; } - // A comma separated list of tracers that provide additional insight into how gRPC C core is processing requests via debug logs. + // A comma separated list of tracers that provide additional insight into how + // gRPC C core is processing requests via debug logs. absl::string_view Trace() const { return trace_; } // Default gRPC logging verbosity absl::string_view Verbosity() const { return verbosity_; } // Messages logged at the same or higher level than this will print stacktrace - absl::string_view StacktraceMinloglevel() const { return stacktrace_minloglevel_; } + absl::string_view StacktraceMinloglevel() const { + return stacktrace_minloglevel_; + } // Enable fork support bool EnableForkSupport() const { return enable_fork_support_; } - // Declares which polling engines to try when starting gRPC. This is a comma-separated list of engines, which are tried in priority order first -> last. + // Declares which polling engines to try when starting gRPC. This is a + // comma-separated list of engines, which are tried in priority order first -> + // last. absl::string_view PollStrategy() const { return poll_strategy_; } - // A debugging aid to cause a call to abort() when gRPC objects are leaked past grpc_shutdown() + // A debugging aid to cause a call to abort() when gRPC objects are leaked + // past grpc_shutdown() bool AbortOnLeaks() const { return abort_on_leaks_; } // Custom directory to SSL Roots std::string SystemSslRootsDir() const; @@ -88,6 +105,7 @@ class GPR_DLL ConfigVars { absl::string_view SslCipherSuites() const { return ssl_cipher_suites_; } // Use absl logging from within gpr_log. bool AbslLogging() const { return absl_logging_; } + private: explicit ConfigVars(const Overrides& overrides); static const ConfigVars& Load(); diff --git a/test/core/util/fuzz_config_vars.cc b/test/core/util/fuzz_config_vars.cc index db88bee9014..7ec3b2382f1 100644 --- a/test/core/util/fuzz_config_vars.cc +++ b/test/core/util/fuzz_config_vars.cc @@ -1,27 +1,29 @@ // Copyright 2023 gRPC authors. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -// +// // Automatically generated by tools/codegen/core/gen_config_vars.py -// +// #include "test/core/util/fuzz_config_vars.h" + #include "test/core/util/fuzz_config_vars_helpers.h" namespace grpc_core { -ConfigVars::Overrides OverridesFromFuzzConfigVars(const grpc::testing::FuzzConfigVars& vars) { +ConfigVars::Overrides OverridesFromFuzzConfigVars( + const grpc::testing::FuzzConfigVars& vars) { ConfigVars::Overrides overrides; if (vars.has_enable_fork_support()) { overrides.enable_fork_support = vars.enable_fork_support(); @@ -36,7 +38,8 @@ ConfigVars::Overrides OverridesFromFuzzConfigVars(const grpc::testing::FuzzConfi overrides.stacktrace_minloglevel = vars.stacktrace_minloglevel(); } if (vars.has_experiments()) { - overrides.experiments = ValidateExperimentsStringForFuzzing(vars.experiments()); + overrides.experiments = + ValidateExperimentsStringForFuzzing(vars.experiments()); } if (vars.has_trace()) { overrides.trace = vars.trace(); diff --git a/test/core/util/fuzz_config_vars.h b/test/core/util/fuzz_config_vars.h index f7691403d0f..47ef57b85c3 100644 --- a/test/core/util/fuzz_config_vars.h +++ b/test/core/util/fuzz_config_vars.h @@ -1,32 +1,33 @@ // Copyright 2023 gRPC authors. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -// +// // Automatically generated by tools/codegen/core/gen_config_vars.py -// +// #ifndef GRPC_TEST_CORE_UTIL_FUZZ_CONFIG_VARS_H #define GRPC_TEST_CORE_UTIL_FUZZ_CONFIG_VARS_H #include -#include "test/core/util/fuzz_config_vars.pb.h" #include "src/core/lib/config/config_vars.h" +#include "test/core/util/fuzz_config_vars.pb.h" namespace grpc_core { -ConfigVars::Overrides OverridesFromFuzzConfigVars(const grpc::testing::FuzzConfigVars& vars); +ConfigVars::Overrides OverridesFromFuzzConfigVars( + const grpc::testing::FuzzConfigVars& vars); void ApplyFuzzConfigVars(const grpc::testing::FuzzConfigVars& vars); } // namespace grpc_core