Class: Gruf::Server
Overview
Represents a gRPC server. Automatically loads and augments gRPC handlers and services based on configuration values.
Instance Attribute Summary collapse
-
#services ⇒ Array<Class>
The services this server is handling.
Instance Method Summary collapse
-
#initialize(services: []) ⇒ Server
constructor
Initialize the server and load and setup the services.
-
#start! ⇒ Object
Start the gRPC server.
Methods included from Loggable
Constructor Details
#initialize(services: []) ⇒ Server
Initialize the server and load and setup the services
33 34 35 36 |
# File 'lib/gruf/server.rb', line 33 def initialize(services: []) setup! load_services(services) end |
Instance Attribute Details
#services ⇒ Array<Class>
Returns The services this server is handling.
26 27 28 |
# File 'lib/gruf/server.rb', line 26 def services @services end |
Instance Method Details
#start! ⇒ Object
Start the gRPC server
:nocov:
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/gruf/server.rb', line 42 def start! logger.info { 'Booting gRPC Server...' } server = GRPC::RpcServer.new server.add_http2_port Gruf.server_binding_url, ssl_credentials services.each do |s| server.handle(s) end server.run_till_terminated logger.info { 'Shutting down gRPC server...' } end |