Class: Grpc::Health::Checker
- Inherits:
-
V1::Health::Service
- Object
- V1::Health::Service
- Grpc::Health::Checker
- Defined in:
- src/ruby/pb/grpc/health/checker.rb
Overview
Checker is implementation of the schema-specified health checking service.
Constant Summary collapse
- StatusCodes =
GRPC::Core::StatusCodes
- HealthCheckResponse =
V1::HealthCheckResponse
Instance Method Summary collapse
-
#add_status(service, status) ⇒ Object
Adds the health status for a given service.
-
#check(req, _call) ⇒ Object
Implements the rpc IDL API method.
-
#clear_all ⇒ Object
Clears alls the statuses.
-
#clear_status(service) ⇒ Object
Clears the status for the given service.
-
#initialize ⇒ Checker
constructor
Initializes the statuses of participating services.
Methods included from GRPC::GenericService
Constructor Details
#initialize ⇒ Checker
Initializes the statuses of participating services
44 45 46 47 |
# File 'src/ruby/pb/grpc/health/checker.rb', line 44 def initialize @statuses = {} @status_mutex = Mutex.new # guards access to @statuses end |
Instance Method Details
#add_status(service, status) ⇒ Object
Adds the health status for a given service.
62 63 64 |
# File 'src/ruby/pb/grpc/health/checker.rb', line 62 def add_status(service, status) @status_mutex.synchronize { @statuses["#{service}"] = status } end |
#check(req, _call) ⇒ Object
Implements the rpc IDL API method
50 51 52 53 54 55 56 57 58 59 |
# File 'src/ruby/pb/grpc/health/checker.rb', line 50 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 |
#clear_all ⇒ Object
Clears alls the statuses.
72 73 74 |
# File 'src/ruby/pb/grpc/health/checker.rb', line 72 def clear_all @status_mutex.synchronize { @statuses = {} } end |
#clear_status(service) ⇒ Object
Clears the status for the given service.
67 68 69 |
# File 'src/ruby/pb/grpc/health/checker.rb', line 67 def clear_status(service) @status_mutex.synchronize { @statuses.delete("#{service}") } end |