Class: ScenarioA

Inherits:
Scenario show all
Defined in:
lib/scenario.rb

Instance Method Summary collapse

Methods inherited from Scenario

register

Instance Method Details

#run(clients) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/scenario.rb', line 15

def run(clients)
  clients.each do |client|
    client.msg 't' => 'STOP'
  end

  rand_clients = clients.sort_by { rand }

  proxy = rand_clients.pop
  rails = rand_clients.pop
  db = rand_clients.pop

  db.msg 't' => 'ROLE', 'role' => 'db', 'slaves' => []
  rails.msg 't' => 'ROLE', 'role' => 'rails', 'db_write' => [db.addr], 'db_read' => [db.addr]
  proxy.msg 't' => 'ROLE', 'role' => 'proxy', 'backends' => [rails.addr]
end