| Index: third_party/grpc/src/ruby/pb/grpc/health/checker.rb
|
| diff --git a/third_party/protobuf/ruby/lib/google/protobuf/message_exts.rb b/third_party/grpc/src/ruby/pb/grpc/health/checker.rb
|
| similarity index 52%
|
| copy from third_party/protobuf/ruby/lib/google/protobuf/message_exts.rb
|
| copy to third_party/grpc/src/ruby/pb/grpc/health/checker.rb
|
| index e10266ba2f3637d655c2de89c285558c987c613b..9f1ee65c41935164c322cde79e7412265010df0e 100644
|
| --- a/third_party/protobuf/ruby/lib/google/protobuf/message_exts.rb
|
| +++ b/third_party/grpc/src/ruby/pb/grpc/health/checker.rb
|
| @@ -1,6 +1,5 @@
|
| -# Protocol Buffers - Google's data interchange format
|
| -# Copyright 2008 Google Inc. All rights reserved.
|
| -# https://developers.google.com/protocol-buffers/
|
| +# Copyright 2015-2016, Google Inc.
|
| +# All rights reserved.
|
| #
|
| # Redistribution and use in source and binary forms, with or without
|
| # modification, are permitted provided that the following conditions are
|
| @@ -28,26 +27,49 @@
|
| # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
| -module Google
|
| - module Protobuf
|
| - module MessageExts
|
| +require 'grpc'
|
| +require 'grpc/health/v1/health_services'
|
| +require 'thread'
|
|
|
| - #this is only called in jruby; mri loades the ClassMethods differently
|
| - def self.included(klass)
|
| - klass.extend(ClassMethods)
|
| +module Grpc
|
| + # Health contains classes and modules that support providing a health check
|
| + # service.
|
| + module Health
|
| + # Checker is implementation of the schema-specified health checking service.
|
| + class Checker < V1::Health::Service
|
| + StatusCodes = GRPC::Core::StatusCodes
|
| + HealthCheckResponse = V1::HealthCheckResponse
|
| +
|
| + # Initializes the statuses of participating services
|
| + def initialize
|
| + @statuses = {}
|
| + @status_mutex = Mutex.new # guards access to @statuses
|
| end
|
|
|
| - module ClassMethods
|
| + # Implements the rpc IDL API method
|
| + def check(req, _call)
|
| + status = nil
|
| + @status_mutex.synchronize do
|
| + status = @statuses["#{req.service}"]
|
| + end
|
| + fail GRPC::BadStatus, StatusCodes::NOT_FOUND if status.nil?
|
| + HealthCheckResponse.new(status: status)
|
| end
|
|
|
| - def to_json
|
| - self.class.encode_json(self)
|
| + # Adds the health status for a given service.
|
| + def add_status(service, status)
|
| + @status_mutex.synchronize { @statuses["#{service}"] = status }
|
| end
|
|
|
| - def to_proto
|
| - self.class.encode(self)
|
| + # Clears the status for the given service.
|
| + def clear_status(service)
|
| + @status_mutex.synchronize { @statuses.delete("#{service}") }
|
| end
|
|
|
| + # Clears alls the statuses.
|
| + def clear_all
|
| + @status_mutex.synchronize { @statuses = {} }
|
| + end
|
| end
|
| end
|
| end
|
|
|