We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 9d2cca3 + 235ef51 commit a72cf28Copy full SHA for a72cf28
job.lua
@@ -652,6 +652,9 @@ function QlessJob:heartbeat(now, worker, data)
652
-- Add this job to the list of jobs handled by this worker
653
redis.call('zadd', 'ql:w:' .. worker .. ':jobs', expires, self.jid)
654
655
+ -- Make sure we this worker to the list of seen workers
656
+ redis.call('zadd', 'ql:workers', now, worker)
657
+
658
-- And now we should just update the locks
659
local queue = Qless.queue(
660
redis.call('hget', QlessJob.ns .. self.jid, 'queue'))
test/test_worker.py
@@ -24,6 +24,24 @@ def test_basic(self):
24
'stalled': 0
25
}])
26
27
+ def test_worker_registration_lapse(self):
28
+ '''Workers that fail to check in expire from the list of active workers'''
29
+ self.lua('config.set', 0, 'max-worker-age', 10)
30
+ self.lua('pop', 1, 'queue', 'worker', 1)
31
+ self.assertEqual(self.lua('workers', 15), {})
32
33
+ def test_worker_heartbeat_registration(self):
34
+ '''Heartbeating registers a worker as being active.'''
35
36
+ self.lua('put', 0, 'worker', 'queue', 'jid', 'klass', {}, 0)
37
38
+ self.lua('heartbeat', 10, 'jid', 'worker', {})
39
+ self.assertEqual(self.lua('workers', 15), [{
40
+ 'name': 'worker',
41
+ 'jobs': 1,
42
+ 'stalled': 0,
43
+ }])
44
45
def test_stalled(self):
46
'''We should be able to detect stalled jobs'''
47
self.lua('put', 0, 'worker', 'queue', 'jid', 'klass', {}, 0)
0 commit comments