15 #ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CONNECTION_OPTIONS_H
16 #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CONNECTION_OPTIONS_H
18 #include "google/cloud/common_options.h"
19 #include "google/cloud/completion_queue.h"
20 #include "google/cloud/grpc_options.h"
21 #include "google/cloud/internal/algorithm.h"
22 #include "google/cloud/internal/background_threads_impl.h"
23 #include "google/cloud/internal/populate_common_options.h"
24 #include "google/cloud/internal/populate_grpc_options.h"
25 #include "google/cloud/options.h"
26 #include "google/cloud/status_or.h"
27 #include "google/cloud/tracing_options.h"
28 #include "google/cloud/version.h"
29 #include <grpcpp/grpcpp.h>
39 template <
typename ConnectionTraits>
40 class ConnectionOptions;
44 template <
typename ConnectionTraits>
45 Options MakeOptions(ConnectionOptions<ConnectionTraits>);
53 template <
typename ConnectionTraits>
54 class ConnectionOptions {
69 std::shared_ptr<grpc::ChannelCredentials> credentials)
73 internal::DefaultTracingComponents()
)
75 internal::DefaultTracingOptions()
)
77 ConnectionTraits::default_endpoint())
79 ConnectionTraits::default_num_channels())),
80 user_agent_prefix_(ConnectionTraits::user_agent_prefix()) {}
87 GOOGLE_CLOUD_CPP_DEPRECATED(
"Use `Options` and `UnifiedCredentialsOption`")
89 std::shared_ptr<grpc::ChannelCredentials> v) {
99 GOOGLE_CLOUD_CPP_DEPRECATED(
"Use `Options` and `UnifiedCredentialsOption`")
115 GOOGLE_CLOUD_CPP_DEPRECATED(
"Use `Options` and `EndpointOption`")
126 GOOGLE_CLOUD_CPP_DEPRECATED(
"Use `Options` and `EndpointOption`")
141 GOOGLE_CLOUD_CPP_DEPRECATED(
"Use `Options` and `GrpcNumChannelsOption`")
149 GOOGLE_CLOUD_CPP_DEPRECATED(
"Use `Options` and `GrpcNumChannelsOption`")
164 GOOGLE_CLOUD_CPP_DEPRECATED(
"Use `Options` and `TracingComponentsOption`")
174 GOOGLE_CLOUD_CPP_DEPRECATED(
"Use `Options` and `TracingComponentsOption`")
185 GOOGLE_CLOUD_CPP_DEPRECATED(
"Use `Options` and `TracingComponentsOption`")
196 GOOGLE_CLOUD_CPP_DEPRECATED(
"Use `Options` and `TracingComponentsOption`")
206 GOOGLE_CLOUD_CPP_DEPRECATED(
"Use `Options` and `GrpcTracingOption`")
229 GOOGLE_CLOUD_CPP_DEPRECATED(
"Use `Options` and `GrpcChannelsArgumentOption`")
231 return channel_pool_domain_;
239 GOOGLE_CLOUD_CPP_DEPRECATED(
"Use `Options` and `GrpcChannelsArgumentsOption`")
241 channel_pool_domain_ = std::move(v);
254 GOOGLE_CLOUD_CPP_DEPRECATED(
"Use `Options` and `UserAgentProductsOption`")
257 prefix += user_agent_prefix_;
258 user_agent_prefix_ = std::move(prefix);
267 GOOGLE_CLOUD_CPP_DEPRECATED(
"Use `Options` and `UserAgentProductsOption`")
280 GOOGLE_CLOUD_CPP_DEPRECATED(
281 "Not intended for use in application code. There is no alternative "
282 "implemented or planned.")
284 return internal::MakeChannelArguments(internal::MakeOptions(*
this));
294 GOOGLE_CLOUD_CPP_DEPRECATED(
295 "Use `Options` and `GrpcBackgroundThreadPoolSizeOption`")
297 background_thread_pool_size_ = s;
302 GOOGLE_CLOUD_CPP_DEPRECATED(
303 "Use `Options` and `GrpcBackgroundThreadPoolSizeOption`")
305 return background_thread_pool_size_;
320 GOOGLE_CLOUD_CPP_DEPRECATED(
"Use `Options` and `GrpcCompletionQueueOption`")
323 background_threads_factory_ = [cq] {
324 return absl::make_unique<internal::CustomerSuppliedBackgroundThreads>(cq);
330 using BackgroundThreadsFactory = ::
google::
cloud::BackgroundThreadsFactory;
334 GOOGLE_CLOUD_CPP_DEPRECATED(
335 "Not intended for applications to use. There is no alternative "
336 "implemented or planned")
338 if (background_threads_factory_)
return background_threads_factory_;
339 auto const s = background_thread_pool_size_;
340 return [s] {
return internal::DefaultBackgroundThreads(s); };
344 template <
typename T>
345 friend Options internal::MakeOptions(ConnectionOptions<T>);
351 std::string user_agent_prefix_;
352 std::string channel_pool_domain_;
353 std::size_t background_thread_pool_size_ = 0;
354 BackgroundThreadsFactory background_threads_factory_;
361 #include "google/cloud/internal/disable_deprecation_warnings.inc"
362 template <
typename ConnectionTraits>
363 Options MakeOptions(ConnectionOptions<ConnectionTraits> old) {
364 Options opts = std::move(old.opts_);
367 old.background_threads_factory());
368 if (!old.channel_pool_domain_.empty()) {
374 {{
"grpc.channel_pooling_domain", std::move(old.channel_pool_domain_)}});
378 #include "google/cloud/internal/diagnostics_pop.inc"