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:
authorStan Hu <stanhu@gmail.com>2018-01-22 02:34:09 +0300
committerStan Hu <stanhu@gmail.com>2018-01-25 02:47:27 +0300
commit867126130946a9d3c3da7ff8e64b59b14da13599 (patch)
treeb67bf98dce78a0b953e63e84ff95a24c60b8af15 /lib/gitlab/gitaly_client/health_check_service.rb
parent44728e0527bc7c5cf982be2fbbd26e24a79e5d8f (diff)
Add a gRPC health check to ensure Gitaly is up
This will enable Geo to skip shards that not operational. Relates to gitlab-org/gitlab-ee#4329
Diffstat (limited to 'lib/gitlab/gitaly_client/health_check_service.rb')
-rw-r--r--lib/gitlab/gitaly_client/health_check_service.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/gitlab/gitaly_client/health_check_service.rb b/lib/gitlab/gitaly_client/health_check_service.rb
new file mode 100644
index 00000000000..6c1213f5e20
--- /dev/null
+++ b/lib/gitlab/gitaly_client/health_check_service.rb
@@ -0,0 +1,19 @@
+module Gitlab
+ module GitalyClient
+ class HealthCheckService
+ def initialize(storage)
+ @storage = storage
+ end
+
+ # Sends a gRPC health ping to the Gitaly server for the storage shard.
+ def check
+ request = Grpc::Health::V1::HealthCheckRequest.new
+ response = GitalyClient.call(@storage, :health_check, :check, request, timeout: GitalyClient.fast_timeout)
+
+ { success: response&.status == :SERVING }
+ rescue GRPC::BadStatus => e
+ { success: false, message: e.to_s }
+ end
+ end
+ end
+end