Class: Gruf::Server

Inherits:
Object
  • Object
show all
Includes:
Loggable
Defined in:
lib/gruf/server.rb

Overview

Represents a gRPC server. Automatically loads and augments gRPC handlers and services based on configuration values.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Loggable

#logger

Constructor Details

#initialize(services: []) ⇒ Server

Initialize the server and load and setup the services

Parameters:

  • services (Array<Class>) (defaults to: [])

    The services that this server should handle



35
36
37
38
# File 'lib/gruf/server.rb', line 35

def initialize(services: [])
  setup!
  load_services(services)
end

Instance Attribute Details

#serverGRPC::RpcServer (readonly)

Returns The GRPC server running.

Returns:

  • (GRPC::RpcServer)

    The GRPC server running



43
44
45
# File 'lib/gruf/server.rb', line 43

def server
  @server
end

#servicesArray<Class>

Returns The services this server is handling.

Returns:

  • (Array<Class>)

    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:



58
59
60
61
62
# File 'lib/gruf/server.rb', line 58

def start!
  logger.info { 'Booting gRPC Server...' }
  server.run_till_terminated
  logger.info { 'Shutting down gRPC server...' }
end