Class: Raft::Goliath

Inherits:
Object
  • Object
show all
Defined in:
lib/raft/goliath.rb

Defined Under Namespace

Modules: HashMarshalling Classes: EventMachineAsyncProvider, HttpJsonRpcProvider, HttpJsonRpcResponder

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#nodeObject (readonly)

Returns the value of attribute node.



220
221
222
# File 'lib/raft/goliath.rb', line 220

def node
  @node
end

#runningObject (readonly)

Returns the value of attribute running.



222
223
224
# File 'lib/raft/goliath.rb', line 222

def running
  @running
end

#update_fiberObject (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_providerObject



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(message)
  #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(options = {})
  @runner = ::Goliath::Runner.new(ARGV, nil)
  @runner.api = HttpJsonRpcResponder.new(node)
  @runner.app = ::Goliath::Rack::Builder.build(HttpJsonRpcResponder, @runner.api)
  @runner.address = options[:address] if options[:address]
  @runner.port = options[:port] if options[: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

#stopObject



242
243
244
# File 'lib/raft/goliath.rb', line 242

def stop
  @update_timer.cancel
end