Class: Norikra::RPC::HTTP
- Inherits:
-
Object
- Object
- Norikra::RPC::HTTP
- Defined in:
- lib/norikra/rpc/http.rb
Constant Summary collapse
- DEFAULT_LISTEN_HOST =
'0.0.0.0'- DEFAULT_LISTEN_PORT =
26571- DEFAULT_THREADS =
26571 = 3026 + 3014 + 2968 + 2950 + 2891 + 2896 + 2975 + 2979 + 2872
2
Instance Attribute Summary collapse
-
#engine ⇒ Object
Returns the value of attribute engine.
-
#host ⇒ Object
Returns the value of attribute host.
-
#mizuno ⇒ Object
Returns the value of attribute mizuno.
-
#port ⇒ Object
Returns the value of attribute port.
-
#thread ⇒ Object
Returns the value of attribute thread.
-
#threads ⇒ Object
Returns the value of attribute threads.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ HTTP
constructor
A new instance of HTTP.
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ HTTP
Returns a new instance of HTTP.
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/norikra/rpc/http.rb', line 18 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 |
Instance Attribute Details
#engine ⇒ Object
Returns the value of attribute engine.
16 17 18 |
# File 'lib/norikra/rpc/http.rb', line 16 def engine @engine end |
#host ⇒ Object
Returns the value of attribute host.
15 16 17 |
# File 'lib/norikra/rpc/http.rb', line 15 def host @host end |
#mizuno ⇒ Object
Returns the value of attribute mizuno.
16 17 18 |
# File 'lib/norikra/rpc/http.rb', line 16 def mizuno @mizuno end |
#port ⇒ Object
Returns the value of attribute port.
15 16 17 |
# File 'lib/norikra/rpc/http.rb', line 15 def port @port end |
#thread ⇒ Object
Returns the value of attribute thread.
16 17 18 |
# File 'lib/norikra/rpc/http.rb', line 16 def thread @thread end |
#threads ⇒ Object
Returns the value of attribute threads.
15 16 17 |
# File 'lib/norikra/rpc/http.rb', line 15 def threads @threads end |
Instance Method Details
#start ⇒ Object
29 30 31 32 33 34 |
# File 'lib/norikra/rpc/http.rb', line 29 def start @thread = Thread.new do @mizuno = Mizuno::Server.new @mizuno.run(@app, :embedded => true, :threads => @threads, :port => @port, :host => @host) end end |
#stop ⇒ Object
36 37 38 39 40 |
# File 'lib/norikra/rpc/http.rb', line 36 def stop @mizuno.stop @thread.kill @thread.join end |