diff options
author | Jacob Vosmaer <jacob@gitlab.com> | 2017-03-22 20:23:40 +0300 |
---|---|---|
committer | Jacob Vosmaer <jacob@gitlab.com> | 2017-03-29 15:48:05 +0300 |
commit | 8f50ef5e75fedc6f8c2a5b1c52e119c4c1df7c4e (patch) | |
tree | 28d6d978e1e80985a5fa53921013f126adb8563f /lib/gitlab/gitaly_client.rb | |
parent | c837da34391094b9d58763a67db5cfb706ca146f (diff) |
Separate GRPC channels per repository storage
Diffstat (limited to 'lib/gitlab/gitaly_client.rb')
-rw-r--r-- | lib/gitlab/gitaly_client.rb | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/lib/gitlab/gitaly_client.rb b/lib/gitlab/gitaly_client.rb index 1ce47ef2b05..c947075bf62 100644 --- a/lib/gitlab/gitaly_client.rb +++ b/lib/gitlab/gitaly_client.rb @@ -4,28 +4,24 @@ module Gitlab module GitalyClient SERVER_VERSION_FILE = 'GITALY_SERVER_VERSION'.freeze - def self.gitaly_address - if Gitlab.config.gitaly.socket_path - "unix://#{Gitlab.config.gitaly.socket_path}" - end + def self.configure_channel(shard, socket_path) + @channel ||= {} + @channel[shard] = new_channel("unix://#{socket_path}") + end + + def self.new_channel(address) + # NOTE: Gitaly currently runs on a Unix socket, so permissions are + # handled using the file system and no additional authentication is + # required (therefore the :this_channel_is_insecure flag) + GRPC::Core::Channel.new(address, {}, :this_channel_is_insecure) end - def self.channel - return @channel if defined?(@channel) - - @channel = - if enabled? - # NOTE: Gitaly currently runs on a Unix socket, so permissions are - # handled using the file system and no additional authentication is - # required (therefore the :this_channel_is_insecure flag) - GRPC::Core::Channel.new(gitaly_address, {}, :this_channel_is_insecure) - else - nil - end + def self.get_channel(shard) + @channel.fetch(shard) end def self.enabled? - gitaly_address.present? + Gitlab.config.gitaly.enabled end def self.feature_enabled?(feature) |