lib/ci/queue/redis/base.rb in ci-queue-0.24.0 vs lib/ci/queue/redis/base.rb in ci-queue-0.24.1
- old
+ new
@@ -20,18 +20,22 @@
def exhausted?
queue_initialized? && size == 0
end
def expired?
- if (created_at = redis.get(key('master-created-at')))
+ if (created_at = redis.get(key('created-at')))
(created_at.to_f + config.redis_ttl + TEN_MINUTES) < Time.now.to_f
else
# if there is no created at set anymore we assume queue is expired
true
end
end
+ def created_at=(timestamp)
+ redis.setnx(key('created-at'), timestamp)
+ end
+
def size
redis.multi do |transaction|
transaction.llen(key('queue'))
transaction.zcard(key('running'))
end.inject(:+)
@@ -67,9 +71,13 @@
def queue_initialized?
@queue_initialized ||= begin
status = master_status
status == 'ready' || status == 'finished'
end
+ end
+
+ def queue_initializing?
+ master_status == 'setup'
end
def increment_test_failed
redis.incr(key('test_failed_count'))
end