Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-01-13 03:07:19 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-01-13 03:07:19 +0300
commit4df596fc09ef7838d439673f5740993e294c4cd6 (patch)
tree8431c7d25cd0dfc701905f3d445c273c98d824ed /lib/gitlab/gitaly_client.rb
parent46c0957d59e2b88b97e6545cb470718869068b13 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/gitaly_client.rb')
-rw-r--r--lib/gitlab/gitaly_client.rb16
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/gitlab/gitaly_client.rb b/lib/gitlab/gitaly_client.rb
index 20eff74c4b1..199257f767d 100644
--- a/lib/gitlab/gitaly_client.rb
+++ b/lib/gitlab/gitaly_client.rb
@@ -37,9 +37,8 @@ module Gitlab
@stubs[storage] ||= {}
@stubs[storage][name] ||= begin
klass = stub_class(name)
- addr = stub_address(storage)
- creds = stub_creds(storage)
- klass.new(addr, creds, interceptors: interceptors, channel_args: channel_args)
+ channel = create_channel(storage)
+ klass.new(channel.target, nil, interceptors: interceptors, channel_override: channel)
end
end
end
@@ -99,9 +98,20 @@ module Gitlab
address(storage).sub(%r{^tcp://|^tls://}, '')
end
+ # Cache gRPC servers by storage. All the client stubs in the same process can share the underlying connection to the
+ # same host thanks to HTTP2 framing protocol that gRPC is built on top. This method is not thread-safe. It is
+ # intended to be a part of `stub`, method behind a mutex protection.
+ def self.create_channel(storage)
+ @channels ||= {}
+ @channels[storage] ||= GRPC::ClientStub.setup_channel(
+ nil, stub_address(storage), stub_creds(storage), channel_args
+ )
+ end
+
def self.clear_stubs!
MUTEX.synchronize do
@stubs = nil
+ @channels = nil
end
end