Skip to content
Snippets Groups Projects
Commit 712cb789 authored by Jan Tattermusch's avatar Jan Tattermusch
Browse files

Merge pull request #6357 from ctiller/split-me-baby-one-more-time

Add a shard channel arg to client channel construction
parents b13382a7 97244d58
No related branches found
No related tags found
No related merge requests found
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#include <vector> #include <vector>
#include <grpc++/support/byte_buffer.h> #include <grpc++/support/byte_buffer.h>
#include <grpc++/support/channel_arguments.h>
#include <grpc++/support/slice.h> #include <grpc++/support/slice.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpc/support/time.h> #include <grpc/support/time.h>
...@@ -280,7 +281,7 @@ class ClientImpl : public Client { ...@@ -280,7 +281,7 @@ class ClientImpl : public Client {
create_stub_(create_stub) { create_stub_(create_stub) {
for (int i = 0; i < config.client_channels(); i++) { for (int i = 0; i < config.client_channels(); i++) {
channels_[i].init(config.server_targets(i % config.server_targets_size()), channels_[i].init(config.server_targets(i % config.server_targets_size()),
config, create_stub_); config, create_stub_, i);
} }
ClientRequestCreator<RequestType> create_req(&request_, ClientRequestCreator<RequestType> create_req(&request_,
...@@ -303,14 +304,17 @@ class ClientImpl : public Client { ...@@ -303,14 +304,17 @@ class ClientImpl : public Client {
} }
void init(const grpc::string& target, const ClientConfig& config, void init(const grpc::string& target, const ClientConfig& config,
std::function<std::unique_ptr<StubType>(std::shared_ptr<Channel>)> std::function<std::unique_ptr<StubType>(std::shared_ptr<Channel>)>
create_stub) { create_stub,
int shard) {
// We have to use a 2-phase init like this with a default // We have to use a 2-phase init like this with a default
// constructor followed by an initializer function to make // constructor followed by an initializer function to make
// old compilers happy with using this in std::vector // old compilers happy with using this in std::vector
ChannelArguments args;
args.SetInt("shard_to_ensure_no_subchannel_merges", shard);
channel_ = CreateTestChannel( channel_ = CreateTestChannel(
target, config.security_params().server_host_override(), target, config.security_params().server_host_override(),
config.has_security_params(), config.has_security_params(), !config.security_params().use_test_ca(),
!config.security_params().use_test_ca()); std::shared_ptr<CallCredentials>(), args);
stub_ = create_stub(channel_); stub_ = create_stub(channel_);
} }
Channel* get_channel() { return channel_.get(); } Channel* get_channel() { return channel_.get(); }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment