Class: Raft::Goliath
- Inherits:
-
Object
- Object
- Raft::Goliath
- Defined in:
- lib/raft/goliath.rb
Defined Under Namespace
Modules: HashMarshalling Classes: EventMachineAsyncProvider, HttpJsonRpcProvider, HttpJsonRpcResponder
Instance Attribute Summary collapse
-
#node ⇒ Object
readonly
Returns the value of attribute node.
-
#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(options = {}) ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(node) ⇒ Goliath
Returns a new instance of Goliath.
216 217 218 |
# File 'lib/raft/goliath.rb', line 216 def initialize(node) @node = node end |
Instance Attribute Details
#node ⇒ Object (readonly)
Returns the value of attribute node.
220 221 222 |
# File 'lib/raft/goliath.rb', line 220 def node @node end |
#running ⇒ Object (readonly)
Returns the value of attribute running.
222 223 224 |
# File 'lib/raft/goliath.rb', line 222 def running @running end |
#update_fiber ⇒ Object (readonly)
Returns the value of attribute update_fiber.
221 222 223 |
# File 'lib/raft/goliath.rb', line 221 def update_fiber @update_fiber end |
Class Method Details
.async_provider ⇒ Object
212 213 214 |
# File 'lib/raft/goliath.rb', line 212 def self.async_provider EventMachineAsyncProvider.new end |
.log(message) ⇒ Object
8 9 10 11 12 |
# File 'lib/raft/goliath.rb', line 8 def self.log() #STDOUT.write("\n\n") #STDOUT.write(message) #STDOUT.write("\n\n") end |
.rpc_provider(uri_generator) ⇒ Object
208 209 210 |
# File 'lib/raft/goliath.rb', line 208 def self.rpc_provider(uri_generator) HttpJsonRpcProvider.new(uri_generator) end |
Instance Method Details
#start(options = {}) ⇒ Object
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 |
# File 'lib/raft/goliath.rb', line 224 def start( = {}) @runner = ::Goliath::Runner.new(ARGV, nil) @runner.api = HttpJsonRpcResponder.new(node) @runner.app = ::Goliath::Rack::Builder.build(HttpJsonRpcResponder, @runner.api) @runner.address = [:address] if [:address] @runner.port = [:port] if [:port] @runner.run @running = true update_proc = Proc.new do EM.synchrony do @node.update end end @update_timer = EventMachine.add_periodic_timer(node.config.update_interval, update_proc) # @node.update end |
#stop ⇒ Object
242 243 244 |
# File 'lib/raft/goliath.rb', line 242 def stop @update_timer.cancel end |