class Grpc::Health::Checker
Checker
is implementation of the schema-specified health checking service.
Constants
- HealthCheckResponse
- StatusCodes
-
StatusCodes
defines the canonical error codes used by gRPC for the RPC API.
Public Class Methods
Source
# File src/ruby/pb/grpc/health/checker.rb, line 28 def initialize @statuses = {} @status_mutex = Mutex.new # guards access to @statuses end
Initializes the statuses of participating services
Public Instance Methods
Source
# File src/ruby/pb/grpc/health/checker.rb, line 46 def add_status(service, status) @status_mutex.synchronize { @statuses["#{service}"] = status } end
Adds the health status for a given service.
Source
# File src/ruby/pb/grpc/health/checker.rb, line 58 def add_statuses(service_statuses = {}) @status_mutex.synchronize do service_statuses.each_pair { |service, status| @statuses["#{service}"] = status } end end
Adds health status for each service given within hash
Source
# File src/ruby/pb/grpc/health/checker.rb, line 34 def check(req, _call) status = nil @status_mutex.synchronize do status = @statuses["#{req.service}"] end if status.nil? fail GRPC::BadStatus.new_status_exception(StatusCodes::NOT_FOUND) end HealthCheckResponse.new(status: status) end
Implements the rpc IDL API method
Source
# File src/ruby/pb/grpc/health/checker.rb, line 70 def clear_all @status_mutex.synchronize { @statuses = {} } end
Clears alls the statuses.
Source
# File src/ruby/pb/grpc/health/checker.rb, line 65 def clear_status(service) @status_mutex.synchronize { @statuses.delete("#{service}") } end
Clears the status for the given service.
Source
# File src/ruby/pb/grpc/health/checker.rb, line 51 def set_status_for_services(status, *services) @status_mutex.synchronize do services.each { |service| @statuses["#{service}"] = status } end end
Adds given health status for all given services