Sha256: 88c958fc1a0a86cd9863612e3f9027c98104d3c39603b6d9e25b99ae9065d371

Contents?: true

Size: 770 Bytes

Versions: 1

Compression:

Stored size: 770 Bytes

Contents

require 'sequel'
require_relative 'addr'
require_relative 'repos'
require_relative 'server/http'
require_relative 'server/tcp'
require_relative 'server/udp'
require_relative 'settings'

module Kamerling
  class ServerRunner
    def initialize(args, classes: def_classes, orm: Sequel, repos: Repos)
      settings = Settings.new(args)
      repos.db = orm.connect(settings.db)
      @servers = settings.server_addrs.map do |type, addr|
        classes[type].new(addr: addr)
      end
    end

    def join
      servers.each(&:join)
    end

    def start
      servers.each(&:start)
      self
    end

    attr_reader :servers
    private     :servers

    private

    def def_classes
      { http: Server::HTTP, tcp: Server::TCP, udp: Server::UDP }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kamerling-0.0.3 lib/kamerling/server_runner.rb