Module: RRRSpec::Server::Persister

Defined in:
lib/rrrspec/server/persister.rb

Constant Summary collapse

SLAVE_EXIT_WAIT_TIME =
15
PERSISTED_RESIDUE_SEC =
60

Class Method Summary collapse

Class Method Details

.workObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/rrrspec/server/persister.rb', line 20

def work
  taskset = PersisterQueue.dequeue
  ActiveRecord::Base.connection_pool.with_connection do
    return if Persistence::Taskset.where(key: taskset.key).exists?
  end

  sleep SLAVE_EXIT_WAIT_TIME

  ActiveRecord::Base.connection_pool.with_connection do
    persist(taskset)
    taskset.expire(PERSISTED_RESIDUE_SEC)
  end

  StatisticsUpdaterQueue.enqueue(taskset)
rescue
  RRRSpec.logger.error($!)
end

.work_loopObject



16
17
18
# File 'lib/rrrspec/server/persister.rb', line 16

def work_loop
  loop { work }
end