Sha256: d6420c199480bf6c47b10a0b0016c97266397921f93c67959dc799d280383a77

Contents?: true

Size: 1.03 KB

Versions: 5

Compression:

Stored size: 1.03 KB

Contents

require 'mizuno/server'
require 'rack/builder'
require 'msgpack-rpc-over-http-jruby'

require_relative 'handler'

module Norikra::RPC
  class HTTP
    DEFAULT_LISTEN_HOST = '0.0.0.0'
    DEFAULT_LISTEN_PORT = 26571
    # 26571 = 3026 + 3014 + 2968 + 2950 + 2891 + 2896 + 2975 + 2979 + 2872

    DEFAULT_THREADS = 2

    attr_accessor :host, :port, :threads
    attr_accessor :engine, :mizuno, :thread

    def initialize(opts={})
      @engine = opts[:engine]
      @host = opts[:host] || DEFAULT_LISTEN_HOST
      @port = opts[:port] || DEFAULT_LISTEN_PORT
      @threads = opts[:threads] || DEFAULT_THREADS
      handler = Norikra::RPC::Handler.new(@engine)
      @app = Rack::Builder.new {
        run MessagePack::RPCOverHTTP::Server.app(handler)
      }
    end

    def start
      @thread = Thread.new do
        @mizuno = Mizuno::Server.new
        @mizuno.run(@app, :embedded => true, :threads => @threads, :port => @port, :host => @host)
      end
    end

    def stop
      @mizuno.stop
      @thread.kill
      @thread.join
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
norikra-0.0.16-java lib/norikra/rpc/http.rb
norikra-0.0.15-java lib/norikra/rpc/http.rb
norikra-0.0.14-java lib/norikra/rpc/http.rb
norikra-0.0.13-java lib/norikra/rpc/http.rb
norikra-0.0.12-java lib/norikra/rpc/http.rb