simpleci-worker 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/lib/worker/queue.rb +15 -4
- data/lib/worker/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 724b1852c4dec6537db709453b0ca9b3f0058fe8
|
4
|
+
data.tar.gz: ad2062d63d27371735b47baf59dc84aaa03ab04c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3728a34c2ce129dc461a34b5cde6559bf57c707b2396b297047db9fb90d1c6d1eead50820fab9b02df6e8a8f27512b6836e1fd1564dd0663a4fe049b66f7849
|
7
|
+
data.tar.gz: 75ead4be80821aaeb335d945031cc71a9cfe0bb082eaa7de2379ce38b0a3cc670f55897f1d03ffce62a4611619480f2b4e68127989d0be70f24c8b88da23ce06
|
data/Gemfile
CHANGED
data/lib/worker/queue.rb
CHANGED
@@ -26,6 +26,8 @@ module Worker
|
|
26
26
|
@poll_interval = opts[:poll_interval] || 5 # 5 second polling
|
27
27
|
@log_backtrace = !!opts[:log_backtrace]
|
28
28
|
|
29
|
+
@db_adapter = db_config[:adapter]
|
30
|
+
|
29
31
|
create_table
|
30
32
|
end
|
31
33
|
|
@@ -61,10 +63,19 @@ module Worker
|
|
61
63
|
|
62
64
|
# locks a set of jobs for this worker
|
63
65
|
def dequeue
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
66
|
+
|
67
|
+
if @db_adapter == 'mysql2' || @db_adapter == 'mysql'
|
68
|
+
query = db[:worker_jobs]
|
69
|
+
.limit(jobs_per_worker)
|
70
|
+
.where('`run_at` < ?', Time.now)
|
71
|
+
.where('`locked_by` IS NULL')
|
72
|
+
.reverse_order('priority')
|
73
|
+
else
|
74
|
+
query = db[:worker_jobs]
|
75
|
+
.where(
|
76
|
+
'`run_at` < ? AND `locked_by` IS NULL AND `id` in (SELECT `id` FROM `worker_jobs` ORDER BY `priority` DESC LIMIT ?)',
|
77
|
+
Time.now, jobs_per_worker)
|
78
|
+
end
|
68
79
|
|
69
80
|
if queue_name
|
70
81
|
query = query.where(queue: queue_name)
|
data/lib/worker/version.rb
CHANGED