Class: Nonnative::GRPCServer
- Defined in:
- lib/nonnative/grpc_server.rb
Overview
gRPC server runner implemented using GRPC::RpcServer.
This is a convenience server implementation for running a gRPC service in-process under Nonnative’s server lifecycle. It binds to the configured proxy host/port and is started/stopped by Server via #perform_start / #perform_stop.
Important note about logging: the grpc gem uses a global logger. This implementation sets GRPC.logger to write to the configured service.log, and whichever gRPC server is initialized first “wins” that global logger.
Instance Attribute Summary
Attributes inherited from Runner
Instance Method Summary collapse
-
#initialize(svc, service) ⇒ GRPCServer
constructor
Creates a gRPC server and registers the provided service handler.
Methods inherited from Server
Methods inherited from Runner
Constructor Details
#initialize(svc, service) ⇒ GRPCServer
Creates a gRPC server and registers the provided service handler.
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/nonnative/grpc_server.rb', line 20 def initialize(svc, service) @server = GRPC::RpcServer.new server.handle(svc) # Unfortunately gRPC has only one logger so the first server wins. GRPC.define_singleton_method(:logger) do @logger ||= Logger.new(service.log) end super(service) end |