Class: Raft::Goliath
- Inherits:
-
Object
- Object
- Raft::Goliath
- Defined in:
- lib/raft/goliath.rb
Defined Under Namespace
Classes: EventMachineAsyncProvider, HttpJsonRpcProvider, HttpJsonRpcResponder
Instance Attribute Summary collapse
-
#running ⇒ Object
readonly
Returns the value of attribute running.
-
#update_fiber ⇒ Object
readonly
Returns the value of attribute update_fiber.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(node) ⇒ Goliath
constructor
A new instance of Goliath.
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(node) ⇒ Goliath
Returns a new instance of Goliath.
118 119 120 |
# File 'lib/raft/goliath.rb', line 118 def initialize(node) end |
Instance Attribute Details
#running ⇒ Object (readonly)
Returns the value of attribute running.
123 124 125 |
# File 'lib/raft/goliath.rb', line 123 def running @running end |
#update_fiber ⇒ Object (readonly)
Returns the value of attribute update_fiber.
122 123 124 |
# File 'lib/raft/goliath.rb', line 122 def update_fiber @update_fiber end |
Class Method Details
.async_provider ⇒ Object
114 115 116 |
# File 'lib/raft/goliath.rb', line 114 def self.async_provider EventMachineAsyncProvider.new end |
.rpc_provider ⇒ Object
110 111 112 |
# File 'lib/raft/goliath.rb', line 110 def self.rpc_provider HttpJsonRpcProvider.new end |
Instance Method Details
#start ⇒ Object
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/raft/goliath.rb', line 125 def start @runner = Goliath::Runner.new(ARGV, nil) @runner.api = HttpJsonRpcResponder.new(node) @runner.app = Goliath::Rack::Builder.build(HttpJsonRpcResponder, runner.api) @runner.run @running = true runner = self @update_fiber = Fiber.new do while runner.running? EventMachine.add_timer node.config.update_interval, Proc.new do runner.update_fiber.resume if runner.running? end @node.update Fiber.yield end end end |
#stop ⇒ Object
145 146 147 148 149 150 151 152 |
# File 'lib/raft/goliath.rb', line 145 def stop @running = false f = Fiber.current while @update_fiber.alive? EventMachine.add_timer 0.1, proc { f.resume } Fiber.yield end end |