Module: RRRSpec::ArbiterQueue
- Defined in:
- lib/rrrspec/redis_models.rb
Constant Summary collapse
- ARBITER_QUEUE_KEY =
'rrrspec:arbiter_queue'
Class Method Summary collapse
-
.cancel(taskset) ⇒ Object
Public: Cancel the taskset.
-
.check(taskset) ⇒ Object
Public: Check if there is no tasks left in the taskset.
-
.dequeue ⇒ Object
Public: Dequeue the task.
-
.fail(taskset) ⇒ Object
Public: Mark taskset failed.
-
.trial(trial) ⇒ Object
Public: Update the status of the task based on the result of the trial.
Class Method Details
.cancel(taskset) ⇒ Object
Public: Cancel the taskset.
73 74 75 |
# File 'lib/rrrspec/redis_models.rb', line 73 def self.cancel(taskset) RRRSpec.redis.rpush(ARBITER_QUEUE_KEY, "cancel\t#{taskset.key}") end |
.check(taskset) ⇒ Object
Public: Check if there is no tasks left in the taskset.
83 84 85 |
# File 'lib/rrrspec/redis_models.rb', line 83 def self.check(taskset) RRRSpec.redis.rpush(ARBITER_QUEUE_KEY, "check\t#{taskset.key}") end |
.dequeue ⇒ Object
Public: Dequeue the task.
Returns [command_name, arg]
95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/rrrspec/redis_models.rb', line 95 def self.dequeue _, line = RRRSpec.redis.blpop(ARBITER_QUEUE_KEY, 0) command, arg = line.split("\t", 2) case command when 'cancel', 'check', 'fail' arg = Taskset.new(arg) when 'trial' arg = Trial.new(arg) else raise 'Unknown command' end return command, arg end |
.fail(taskset) ⇒ Object
Public: Mark taskset failed
78 79 80 |
# File 'lib/rrrspec/redis_models.rb', line 78 def self.fail(taskset) RRRSpec.redis.rpush(ARBITER_QUEUE_KEY, "fail\t#{taskset.key}") end |
.trial(trial) ⇒ Object
Public: Update the status of the task based on the result of the trial.
88 89 90 |
# File 'lib/rrrspec/redis_models.rb', line 88 def self.trial(trial) RRRSpec.redis.rpush(ARBITER_QUEUE_KEY, "trial\t#{trial.key}") end |