Class: RailsGrpc::Boot

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_grpc/boot.rb

Constant Summary collapse

GRPC_DEFAULT_PORT =
"127.0.0.1:5050"
GRPC_DEFAULT_POOL_SIZE =
1
RAILS_BOOT_PATH =
"config/environment.rb"
GRPC_CONFIG_PATH =
"config/grpc.yml"

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#serverObject

Returns the value of attribute server.



3
4
5
# File 'lib/rails_grpc/boot.rb', line 3

def server
  @server
end

Instance Method Details

#exec(environment) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/rails_grpc/boot.rb', line 10

def exec(environment)
  require File.expand_path(RAILS_BOOT_PATH) # Load rails
  require "rails_grpc/general_server"

  c = config[environment]
  @server = RailsGrpc::GeneralServer.new(
    port: c["server"]["port"] || GRPC_DEFAULT_PORT,
    pool_size: c["server"]["pool_size"] || GRPC_DEFAULT_POOL_SIZE
  )
  @server.set_handlers(c["handlers"].map(&:constantize))
  @server.run
end