boy_band 0.1.9 → 0.1.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/boy_band.rb +24 -13
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7bb0ed487c254092a58036d84d154080993a6d82a8fc21db12e69781643fc614
|
4
|
+
data.tar.gz: a2f5dd392d8d591205cdf2b0d75b0682ef82f5f1ac7fa759f44533a057b2d847
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21f05cb1669ac54fdc77668a0b80708092e997a832abc504872c2be5aee145b66e3bd3ff4a79b80dafb6ede62a6838d0785de9665db9e8de00f51acaf5f55fa6
|
7
|
+
data.tar.gz: 06c726f35e6c6dafe8ee6baa8ac6ec7acc37b12980b85b5f9712ec132af92912079625050cb0b9d739b3c5cc13428e2ff55dc28c3ac62519bf310cdd685a1892
|
data/lib/boy_band.rb
CHANGED
@@ -39,13 +39,22 @@ module BoyBand
|
|
39
39
|
def set_job_chain(val)
|
40
40
|
@@job_chain = val
|
41
41
|
end
|
42
|
+
|
43
|
+
def queue_size(queue)
|
44
|
+
size = Resque.redis.get("sizeof/#{queue}").to_i
|
45
|
+
if !size || size == 0
|
46
|
+
size = Resque.size(queue)
|
47
|
+
Resque.redis.setex("sizeof/#{queue}", 30.seconds.to_i, size)
|
48
|
+
end
|
49
|
+
size
|
50
|
+
end
|
42
51
|
|
43
52
|
def schedule_for(queue, klass, method_name, *args)
|
44
53
|
queue = queue.to_sym
|
45
54
|
@queue = queue.to_s
|
46
55
|
job_hash = Digest::MD5.hexdigest(args.to_json)
|
47
56
|
note_job(job_hash)
|
48
|
-
size =
|
57
|
+
size = queue_size(queue)
|
49
58
|
args.push("domain::#{self.domain_id}")
|
50
59
|
chain = self.job_chain.split(/##/)
|
51
60
|
job_id = "j#{Time.now.iso8601}_#{rand(9999)}"
|
@@ -80,21 +89,21 @@ module BoyBand
|
|
80
89
|
end
|
81
90
|
|
82
91
|
def note_job(hash)
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
# Resque.redis.hset('hashed_jobs', hash, timestamps.to_json)
|
89
|
-
|
92
|
+
# if Resque.redis
|
93
|
+
# timestamps = JSON.parse(Resque.redis.hget('hashed_jobs', hash) || "[]")
|
94
|
+
# cutoff = 6.hours.ago.to_i
|
95
|
+
# timestamps = timestamps.select{|ts| ts > cutoff }
|
96
|
+
# timestamps.push(Time.now.to_i)
|
97
|
+
# # Resque.redis.hset('hashed_jobs', hash, timestamps.to_json)
|
98
|
+
# end
|
90
99
|
end
|
91
100
|
|
92
101
|
def clear_job(hash)
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
# Resque.redis.hset('hashed_jobs', hash, timestamps.to_json)
|
97
|
-
|
102
|
+
# if Resque.redis
|
103
|
+
# timestamps = JSON.parse(Resque.redis.hget('hashed_jobs', hash) || "[]")
|
104
|
+
# timestamps.shift
|
105
|
+
# # Resque.redis.hset('hashed_jobs', hash, timestamps.to_json)
|
106
|
+
# end
|
98
107
|
end
|
99
108
|
|
100
109
|
def schedule(klass, method_name, *args)
|
@@ -251,6 +260,8 @@ module BoyBand
|
|
251
260
|
set_domain_id(args_copy.pop.split(/::/, 2)[1])
|
252
261
|
end
|
253
262
|
|
263
|
+
idx = queue_size(queue)
|
264
|
+
return false if idx > 500 # big queues mustn't be searched this way
|
254
265
|
idx = Resque.size(queue)
|
255
266
|
queue_class = (queue == :slow ? 'SlowWorker' : 'Worker')
|
256
267
|
if false
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: boy_band
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Whitmer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-02-
|
11
|
+
date: 2020-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|