module Grpcx::Server

Constants

ServingStatus

Public Class Methods

new(**opts) click to toggle source
Calls superclass method
# File lib/grpcx/server.rb, line 25
def initialize(**opts)
  opts[:pool_size] ||= ENV['GRPC_SERVER_THREADS'].to_i if ENV['GRPC_SERVER_THREADS']
  opts[:max_waiting_requests] ||= ENV['GRPC_SERVER_QUEUE'].to_i if ENV['GRPC_SERVER_QUEUE']

  # interceptors are fired in FIFO order.
  opts[:interceptors] ||= []
  opts[:interceptors].prepend Grpcx::Server::Interceptors::Rescue.new(self)
  opts[:interceptors].prepend Grpcx::Server::Interceptors::Instrumentation.new
  opts[:interceptors].prepend Grpcx::Server::Interceptors::ActiveRecord.new if defined?(::ActiveRecord)

  super.tap do
    handle(health)
  end
end

Public Instance Methods

handle(service) click to toggle source
Calls superclass method
# File lib/grpcx/server.rb, line 40
def handle(service)
  service_name = nil
  if service.is_a?(Class) && service < GRPC::GenericService
    service_name = service.service_name
  elsif service.is_a?(GRPC::GenericService)
    service_name = service.class.service_name
  end

  health.add_status(service_name, ServingStatus::SERVING) if service_name
  super
end
health() click to toggle source
# File lib/grpcx/server.rb, line 52
def health
  @health ||= ::Grpc::Health::Checker.new
end