grpcpp/support/channel_arguments.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_H
20 #define GRPCPP_SUPPORT_CHANNEL_ARGUMENTS_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 class SecureChannelCredentials;
32 namespace testing {
33 class ChannelArgumentsTest;
34 } // namespace testing
35 
40  public:
43 
44  ChannelArguments(const ChannelArguments& other);
46  Swap(other);
47  return *this;
48  }
49 
50  void Swap(ChannelArguments& other);
51 
57  void SetChannelArgs(grpc_channel_args* channel_args) const;
58 
59  // gRPC specific channel argument setters
63  // TODO(yangg) add flow control options
66 
71  void SetGrpclbFallbackTimeout(int fallback_timeout);
72 
75 
77  void SetUserAgentPrefix(const std::string& user_agent_prefix);
78 
81 
84  void SetMaxSendMessageSize(int size);
85 
89  void SetLoadBalancingPolicyName(const std::string& lb_policy_name);
90 
93  void SetServiceConfigJSON(const std::string& service_config_json);
94 
95  // Generic channel argument setter. Only for advanced use cases.
97  void SetInt(const std::string& key, int value);
98 
99  // Generic channel argument setter. Only for advanced use cases.
102  void SetPointer(const std::string& key, void* value);
103 
107  void SetPointerWithVtable(const std::string& key, void* value,
109 
111  void SetString(const std::string& key, const std::string& value);
112 
117  out.num_args = args_.size();
118  out.args = args_.empty() ? nullptr : const_cast<grpc_arg*>(&args_[0]);
119  return out;
120  }
121 
122  private:
125 
128  static void* Copy(void* in) { return in; }
129  static void Destroy(void* /*in*/) {}
130  static int Compare(void* a, void* b) {
131  if (a < b) return -1;
132  if (a > b) return 1;
133  return 0;
134  }
135  };
136 
137  // Returns empty string when it is not set.
139 
140  std::vector<grpc_arg> args_;
141  std::list<std::string> strings_;
142 };
143 
144 } // namespace grpc
145 
146 #endif // GRPCPP_SUPPORT_CHANNEL_ARGUMENTS_H
grpc_arg
Definition: grpc_types.h:103
compression.h
testing
Definition: aws_request_signer_test.cc:25
gen_build_yaml.out
dictionary out
Definition: src/benchmark/gen_build_yaml.py:24
vtable
static const grpc_transport_vtable vtable
Definition: binder_transport.cc:680
grpc::ChannelArguments::SetGrpclbFallbackTimeout
void SetGrpclbFallbackTimeout(int fallback_timeout)
Definition: channel_arguments.cc:92
grpc::ChannelArguments::Swap
void Swap(ChannelArguments &other)
Definition: channel_arguments.cc:82
grpc
Definition: grpcpp/alarm.h:33
grpc::ChannelArguments::SetChannelArgs
void SetChannelArgs(grpc_channel_args *channel_args) const
Definition: channel_arguments.cc:215
grpc_compression_algorithm
grpc_compression_algorithm
Definition: compression_types.h:60
grpc::testing::ChannelArgumentsTest
Definition: channel_arguments_test.cc:77
grpc::ChannelArguments::SetString
void SetString(const std::string &key, const std::string &value)
Set a textual argument value under key.
Definition: channel_arguments.cc:203
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
grpc::ResourceQuota
Definition: include/grpcpp/resource_quota.h:34
grpc::ChannelArguments::GetSslTargetNameOverride
std::string GetSslTargetNameOverride() const
Definition: secure_channel_arguments.cc:33
setup.name
name
Definition: setup.py:542
a
int a
Definition: abseil-cpp/absl/container/internal/hash_policy_traits_test.cc:88
grpc::ChannelArguments::SetSocketMutator
void SetSocketMutator(grpc_socket_mutator *mutator)
Set a mutator for the underlying socket.
Definition: channel_arguments.cc:96
grpc::ChannelArguments::PointerVtableMembers
Default pointer argument operations.
Definition: grpcpp/support/channel_arguments.h:127
grpc::ChannelArguments::SetCompressionAlgorithm
void SetCompressionAlgorithm(grpc_compression_algorithm algorithm)
Set the compression algorithm for the channel.
Definition: channel_arguments.cc:87
grpc::ChannelArguments::SetUserAgentPrefix
void SetUserAgentPrefix(const std::string &user_agent_prefix)
Set the string to prepend to the user agent.
Definition: channel_arguments.cc:124
grpc::ChannelArguments::PointerVtableMembers::Destroy
static void Destroy(void *)
Definition: grpcpp/support/channel_arguments.h:129
grpc_arg_pointer_vtable
Definition: grpc_types.h:85
grpc_channel_args
Definition: grpc_types.h:132
resource_quota
ResourceQuotaRefPtr resource_quota
Definition: filter_fuzzer.cc:145
grpc::ChannelArguments::SetMaxReceiveMessageSize
void SetMaxReceiveMessageSize(int size)
Set the max receive and send message sizes.
Definition: channel_arguments.cc:156
grpc::ChannelArguments::args_
std::vector< grpc_arg > args_
Definition: grpcpp/support/channel_arguments.h:140
grpc::ChannelArguments::SetMaxSendMessageSize
void SetMaxSendMessageSize(int size)
Definition: channel_arguments.cc:160
in
const char * in
Definition: third_party/abseil-cpp/absl/strings/internal/str_format/parser_test.cc:391
grpc::ChannelArguments::~ChannelArguments
~ChannelArguments()
Definition: channel_arguments.cc:73
grpc::ChannelArguments::SetResourceQuota
void SetResourceQuota(const grpc::ResourceQuota &resource_quota)
Set the buffer pool to be attached to the constructed channel.
Definition: channel_arguments.cc:149
grpc::ChannelArguments::PointerVtableMembers::Copy
static void * Copy(void *in)
Definition: grpcpp/support/channel_arguments.h:128
grpc.h
grpc::ChannelArguments::PointerVtableMembers::Compare
static int Compare(void *a, void *b)
Definition: grpcpp/support/channel_arguments.h:130
b
uint64_t b
Definition: abseil-cpp/absl/container/internal/layout_test.cc:53
config.h
grpc_socket_mutator
Definition: socket_mutator.h:62
value
const char * value
Definition: hpack_parser_table.cc:165
grpc::ChannelArguments
Definition: grpcpp/support/channel_arguments.h:39
grpc::ChannelArguments::SetPointerWithVtable
void SetPointerWithVtable(const std::string &key, void *value, const grpc_arg_pointer_vtable *vtable)
Definition: channel_arguments.cc:191
key
const char * key
Definition: hpack_parser_table.cc:164
grpc::ChannelArguments::SetSslTargetNameOverride
void SetSslTargetNameOverride(const std::string &name)
Definition: secure_channel_arguments.cc:29
grpc::ChannelArguments::operator=
ChannelArguments & operator=(ChannelArguments other)
Definition: grpcpp/support/channel_arguments.h:45
grpc::ChannelArguments::strings_
std::list< std::string > strings_
Definition: grpcpp/support/channel_arguments.h:141
grpc::ChannelArguments::ChannelArguments
ChannelArguments()
Definition: channel_arguments.cc:37
grpc::ChannelArguments::SetLoadBalancingPolicyName
void SetLoadBalancingPolicyName(const std::string &lb_policy_name)
Definition: channel_arguments.cc:164
grpc::ChannelArguments::c_channel_args
grpc_channel_args c_channel_args() const
Definition: grpcpp/support/channel_arguments.h:115
grpc::SecureChannelCredentials
Definition: secure_credentials.h:49
grpc::ChannelArguments::SetInt
void SetInt(const std::string &key, int value)
Set an integer argument value under key.
Definition: channel_arguments.cc:174
resource_quota.h
grpc::ChannelArguments::SetServiceConfigJSON
void SetServiceConfigJSON(const std::string &service_config_json)
Definition: channel_arguments.cc:169
size
voidpf void uLong size
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
grpc::ChannelArguments::SetPointer
void SetPointer(const std::string &key, void *value)
Definition: channel_arguments.cc:184


grpc
Author(s):
autogenerated on Fri May 16 2025 02:57:52