class DoubleDecker::BusData
Attributes
run_id[R]
store[R]
Public Class Methods
new(run_id, store)
click to toggle source
# File src/double_decker/bus_data.rb, line 7 def initialize(run_id, store) @run_id = run_id @store = store end
Public Instance Methods
active_agents()
click to toggle source
# File src/double_decker/bus_data.rb, line 30 def active_agents store.get("#{run_id}_agents").to_i end
merge(agent_id, hash)
click to toggle source
# File src/double_decker/bus_data.rb, line 34 def merge(agent_id, hash) data = to_h || {} data[agent_id.to_s] ||= {} data[agent_id.to_s].merge!(hash) store.set(run_id, data.to_json) end
setup_agent()
click to toggle source
# File src/double_decker/bus_data.rb, line 17 def setup_agent store.incr("#{run_id}_agents").to_i end
teardown_agent()
click to toggle source
# File src/double_decker/bus_data.rb, line 26 def teardown_agent store.decr("#{run_id}_agents").to_i end
teardown_bus()
click to toggle source
# File src/double_decker/bus_data.rb, line 21 def teardown_bus store.del(run_id) store.del("#{run_id}_agents") end
to_h()
click to toggle source
# File src/double_decker/bus_data.rb, line 12 def to_h data = store.get(run_id) data && JSON.parse(data) end