Skip to content

Commit

Permalink
Only store channel if use_cached_channel is true
Browse files Browse the repository at this point in the history
  • Loading branch information
HennerM committed Apr 11, 2024
1 parent c791606 commit 958386c
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/c++/library/grpc_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,15 @@ GetStub(
grpc::CreateCustomChannel(url, credentials, arguments);
std::shared_ptr<inference::GRPCInferenceService::Stub> stub =
inference::GRPCInferenceService::NewStub(channel);
// Replace if channel / stub have been in the map
if (channel_itr != grpc_channel_stub_map_.end()) {
channel_itr->second = std::make_tuple(1, channel, stub);
} else {
grpc_channel_stub_map_.insert(
std::make_pair(url, std::make_tuple(1, channel, stub)));

if (use_cached_channel) {
// Replace if channel / stub have been in the map
if (channel_itr != grpc_channel_stub_map_.end()) {
channel_itr->second = std::make_tuple(1, channel, stub);
} else {
grpc_channel_stub_map_.insert(
std::make_pair(url, std::make_tuple(1, channel, stub)));
}
}

return stub;
Expand Down

0 comments on commit 958386c

Please sign in to comment.