1818#include " google/cloud/connection_options.h"
1919#include " google/cloud/grpc_options.h"
2020#include " google/cloud/internal/getenv.h"
21+ #include " google/cloud/internal/populate_common_options.h"
22+ #include " google/cloud/internal/populate_grpc_options.h"
2123#include " google/cloud/internal/user_agent_prefix.h"
2224#include " google/cloud/options.h"
2325#include < chrono>
@@ -39,26 +41,13 @@ std::size_t DefaultThreadCount() {
3941}
4042
4143Options DefaultCommonOptions (Options opts) {
42- auto emulator = internal::GetEnv (" PUBSUB_EMULATOR_HOST" );
43- if (emulator.has_value ()) {
44- opts.set <EndpointOption>(*emulator).set <GrpcCredentialOption>(
45- grpc::InsecureChannelCredentials ());
46- }
47- if (!opts.has <EndpointOption>()) {
48- opts.set <EndpointOption>(" pubsub.googleapis.com" );
49- }
50- if (!opts.has <GrpcCredentialOption>()) {
51- opts.set <GrpcCredentialOption>(grpc::GoogleDefaultCredentials ());
52- }
44+ opts = internal::PopulateCommonOptions (
45+ std::move (opts), " " , " PUBSUB_EMULATOR_HOST" , " pubsub.googleapis.com" );
46+ opts = internal::PopulateGrpcOptions (std::move (opts), " PUBSUB_EMULATOR_HOST" );
47+
5348 if (!opts.has <GrpcNumChannelsOption>()) {
5449 opts.set <GrpcNumChannelsOption>(static_cast <int >(DefaultThreadCount ()));
5550 }
56- if (!opts.has <TracingComponentsOption>()) {
57- opts.set <TracingComponentsOption>(internal::DefaultTracingComponents ());
58- }
59- if (!opts.has <GrpcTracingOptionsOption>()) {
60- opts.set <GrpcTracingOptionsOption>(internal::DefaultTracingOptions ());
61- }
6251 if (!opts.has <pubsub::RetryPolicyOption>()) {
6352 opts.set <pubsub::RetryPolicyOption>(
6453 pubsub::LimitedTimeRetryPolicy (std::chrono::seconds (60 )).clone ());
@@ -77,10 +66,6 @@ Options DefaultCommonOptions(Options opts) {
7766 auto & num_channels = opts.lookup <GrpcNumChannelsOption>();
7867 num_channels = (std::max)(num_channels, 1 );
7968
80- // Inserts our user-agent string at the front.
81- auto & products = opts.lookup <UserAgentProductsOption>();
82- products.insert (products.begin (), internal::UserAgentPrefix ());
83-
8469 return opts;
8570}
8671
0 commit comments