GRPC C++  1.30.0
channel_arguments_impl.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2015 gRPC authors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 #ifndef GRPCPP_SUPPORT_CHANNEL_ARGUMENTS_IMPL_H
20 #define GRPCPP_SUPPORT_CHANNEL_ARGUMENTS_IMPL_H
21 
22 #include <list>
23 #include <vector>
24 
25 #include <grpc/compression.h>
26 #include <grpc/grpc.h>
27 #include <grpcpp/resource_quota.h>
28 #include <grpcpp/support/config.h>
29 
30 namespace grpc {
31 namespace testing {
32 class ChannelArgumentsTest;
33 } // namespace testing
34 } // namespace grpc
35 
36 namespace grpc_impl {
37 
39 
44  public:
47 
48  ChannelArguments(const ChannelArguments& other);
50  Swap(other);
51  return *this;
52  }
53 
54  void Swap(ChannelArguments& other);
55 
61  void SetChannelArgs(grpc_channel_args* channel_args) const;
62 
63  // gRPC specific channel argument setters
66  void SetSslTargetNameOverride(const grpc::string& name);
67  // TODO(yangg) add flow control options
70 
75  void SetGrpclbFallbackTimeout(int fallback_timeout);
76 
85 
87  void SetUserAgentPrefix(const grpc::string& user_agent_prefix);
88 
90  void SetResourceQuota(const grpc::ResourceQuota& resource_quota);
91 
93  void SetMaxReceiveMessageSize(int size);
94  void SetMaxSendMessageSize(int size);
95 
99  void SetLoadBalancingPolicyName(const grpc::string& lb_policy_name);
100 
103  void SetServiceConfigJSON(const grpc::string& service_config_json);
104 
105  // Generic channel argument setters. Only for advanced use cases.
107  void SetInt(const grpc::string& key, int value);
108 
109  // Generic channel argument setter. Only for advanced use cases.
111  void SetPointer(const grpc::string& key, void* value);
112 
113  void SetPointerWithVtable(const grpc::string& key, void* value,
114  const grpc_arg_pointer_vtable* vtable);
115 
117  void SetString(const grpc::string& key, const grpc::string& value);
118 
122  grpc_channel_args out;
123  out.num_args = args_.size();
124  out.args = args_.empty() ? NULL : const_cast<grpc_arg*>(&args_[0]);
125  return out;
126  }
127 
128  private:
131 
133  struct PointerVtableMembers {
134  static void* Copy(void* in) { return in; }
135  static void Destroy(void* /*in*/) {}
136  static int Compare(void* a, void* b) {
137  if (a < b) return -1;
138  if (a > b) return 1;
139  return 0;
140  }
141  };
142 
143  // Returns empty string when it is not set.
144  grpc::string GetSslTargetNameOverride() const;
145 
146  std::vector<grpc_arg> args_;
147  std::list<grpc::string> strings_;
148 };
149 
150 } // namespace grpc_impl
151 
152 #endif // GRPCPP_SUPPORT_CHANNEL_ARGUMENTS_IMPL_H
compression.h
grpc_socket_mutator
struct grpc_socket_mutator grpc_socket_mutator
The Socket Mutator interface allows changes on socket options.
Definition: grpc_types.h:73
grpc
This header provides an object that reads bytes directly from a grpc::ByteBuffer, via the ZeroCopyInp...
Definition: alarm.h:24
grpc_impl::ChannelArguments::c_channel_args
grpc_channel_args c_channel_args() const
Return (by value) a C grpc_channel_args structure which points to arguments owned by this ChannelArgu...
Definition: channel_arguments_impl.h:121
grpc_compression_algorithm
grpc_compression_algorithm
The various compression algorithms supported by gRPC (not sorted by compression level)
Definition: compression_types.h:57
grpc_impl::ChannelArguments::SetServiceConfigJSON
void SetServiceConfigJSON(const grpc::string &service_config_json)
Set service config in JSON form.
grpc_impl::ChannelArguments::SetCompressionAlgorithm
void SetCompressionAlgorithm(grpc_compression_algorithm algorithm)
Set the compression algorithm for the channel.
grpc_arg_pointer_vtable
Definition: grpc_types.h:85
grpc_channel_args
An array of arguments that can be passed around.
Definition: grpc_types.h:132
grpc_impl::ChannelArguments::SetString
void SetString(const grpc::string &key, const grpc::string &value)
Set a textual argument value under key.
grpc_impl::ChannelArguments::SetPointerWithVtable
void SetPointerWithVtable(const grpc::string &key, void *value, const grpc_arg_pointer_vtable *vtable)
grpc_impl::ChannelArguments::SetGrpclbFallbackTimeout
void SetGrpclbFallbackTimeout(int fallback_timeout)
Set the grpclb fallback timeout (in ms) for the channel.
grpc_impl::ChannelArguments::operator=
ChannelArguments & operator=(ChannelArguments other)
Definition: channel_arguments_impl.h:49
grpc_impl::ChannelArguments::SetPointer
void SetPointer(const grpc::string &key, void *value)
Set a pointer argument value under key. Owership is not transferred.
grpc_impl::ChannelArguments::SetInt
void SetInt(const grpc::string &key, int value)
Set an integer argument value under key.
grpc_impl::ChannelArguments::Swap
void Swap(ChannelArguments &other)
grpc_impl::ResourceQuota
ResourceQuota represents a bound on memory and thread usage by the gRPC library.
Definition: resource_quota_impl.h:34
grpc_impl::ChannelArguments::SetLoadBalancingPolicyName
void SetLoadBalancingPolicyName(const grpc::string &lb_policy_name)
Set LB policy name.
grpc.h
grpc_channel_args::num_args
size_t num_args
Definition: grpc_types.h:133
grpc_impl::ChannelArguments::SetUserAgentPrefix
void SetUserAgentPrefix(const grpc::string &user_agent_prefix)
Set the string to prepend to the user agent.
grpc_impl::ChannelArguments
Options for channel creation.
Definition: channel_arguments_impl.h:43
grpc_impl::ChannelArguments::SetSocketMutator
void SetSocketMutator(grpc_socket_mutator *mutator)
For client channel's, the socket mutator operates on "channel" sockets.
grpc_impl::ChannelArguments::ChannelArgumentsTest
friend class grpc::testing::ChannelArgumentsTest
Definition: channel_arguments_impl.h:130
grpc_impl::ChannelArguments::SetMaxSendMessageSize
void SetMaxSendMessageSize(int size)
grpc_impl::ChannelArguments::SetChannelArgs
void SetChannelArgs(grpc_channel_args *channel_args) const
Dump arguments in this instance to channel_args.
grpc::SecureChannelCredentials
::grpc_impl::SecureChannelCredentials SecureChannelCredentials
Definition: credentials.h:30
resource_quota.h
config.h
grpc_impl::ChannelArguments::SetResourceQuota
void SetResourceQuota(const grpc::ResourceQuota &resource_quota)
Set the buffer pool to be attached to the constructed channel.
grpc::string
std::string string
Definition: config.h:35
grpc_impl
An Alarm posts the user-provided tag to its associated completion queue or invokes the user-provided ...
Definition: alarm_impl.h:33
grpc_impl::ChannelArguments::~ChannelArguments
~ChannelArguments()
grpc_impl::ChannelArguments::ChannelArguments
ChannelArguments()
grpc_channel_args::args
grpc_arg * args
Definition: grpc_types.h:134
grpc_impl::ChannelArguments::SetSslTargetNameOverride
void SetSslTargetNameOverride(const grpc::string &name)
Set target name override for SSL host name checking.
grpc_impl::ChannelArguments::SetMaxReceiveMessageSize
void SetMaxReceiveMessageSize(int size)
Set the max receive and send message sizes.