boy_band 0.1.10 → 0.1.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/boy_band.rb +26 -33
- metadata +6 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 336f5c63c5ed28315ec34a2cba67c8dc9405a086a5b726eaa7ef225692b8cd81
|
4
|
+
data.tar.gz: 230890fc8b4b23f7e7c2510587333fc96f315d300dac2596f6637210458015fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e93e0671fc8314c49f92bbdd290e4053a53894fab37b1d75e3232af87099b2c8646d2c096e918bdb94fa258a29145a9d05aba75f6d3b5c1c038192d159c71215
|
7
|
+
data.tar.gz: f39f01817a3cb7157162597532621e43a69721bd89fe3aabe2c79f27bdf986f96fd403f65e7631ab561fc9bcebe25537f168d03f9d992c20969ac8e84a7d25b6
|
data/lib/boy_band.rb
CHANGED
@@ -63,16 +63,21 @@ module BoyBand
|
|
63
63
|
Resque.redis.incr("jobs_from_#{chain[0]}")
|
64
64
|
Resque.redis.expire("jobs_from_#{chain[0]}", 24.hours.to_i)
|
65
65
|
end
|
66
|
-
|
67
|
-
|
66
|
+
Resque.redis.setex("scheduled/#{klass.to_s}/#{job_hash}", 6.hours, "t")
|
67
|
+
chain_args = args[0..-2]
|
68
|
+
if chain_args.length == 1 && chain_args[0].is_a?(Hash)
|
69
|
+
chain_args = [chain_args[0]['method'],chain_args[0]['id'],chain_args[0]['arguments'].to_s[0, 20]]
|
70
|
+
end
|
71
|
+
chain.push("#{klass.to_s},#{method_name.to_s},#{chain_args.join('+')}")
|
72
|
+
# Rails.logger.warn("jobchain set, #{chain[0]} #{chain.join('##')}") if chain.length > 2
|
68
73
|
if chain.length > 5
|
69
|
-
Rails.logger.error("jobchain too deep: #{chain[
|
74
|
+
Rails.logger.error("jobchain too deep: #{chain[1]}, #{chain.length} entries")
|
70
75
|
end
|
71
76
|
job_count = Resque.redis.get("jobs_from_#{chain[0]}")
|
72
77
|
if job_count && job_count.to_i > 50
|
73
|
-
Rails.logger.error("jobchain too many sub-jobs: #{chain[
|
78
|
+
Rails.logger.error("jobchain too many sub-jobs: #{chain[1]}, #{job_count} so far")
|
74
79
|
end
|
75
|
-
args.push("chain::#{chain.join('##')}")
|
80
|
+
args.push("chain::#{chain[0, 50].join('##')}")
|
76
81
|
if queue == :slow
|
77
82
|
Resque.enqueue(SlowWorker, klass.to_s, method_name, *args)
|
78
83
|
if size > 1000 && !Resque.redis.get("queue_warning_#{queue}")
|
@@ -121,8 +126,13 @@ module BoyBand
|
|
121
126
|
def in_worker_process?
|
122
127
|
BoyBand.job_instigator.match(/^job/)
|
123
128
|
end
|
129
|
+
|
130
|
+
def current_speed
|
131
|
+
@speed
|
132
|
+
end
|
124
133
|
|
125
134
|
def perform_at(speed, *args)
|
135
|
+
@speed = speed
|
126
136
|
args_copy = [] + args
|
127
137
|
if args_copy[-1].is_a?(String) && args_copy[-1].match(/^chain::/)
|
128
138
|
set_job_chain(args_copy.pop.split(/::/, 2)[1])
|
@@ -134,6 +144,7 @@ module BoyBand
|
|
134
144
|
klass = Object.const_get(klass_string)
|
135
145
|
method_name = args_copy.shift
|
136
146
|
job_hash = Digest::MD5.hexdigest(args_copy.to_json)
|
147
|
+
Resque.redis.del("scheduled/#{klass_string}/#{method_name}/#{job_hash}")
|
137
148
|
hash = args_copy[0] if args_copy[0].is_a?(Hash)
|
138
149
|
hash ||= {'method' => method_name}
|
139
150
|
action = "#{klass_string} . #{hash['method']} (#{hash['id']})"
|
@@ -154,6 +165,7 @@ module BoyBand
|
|
154
165
|
set_job_chain("none")
|
155
166
|
BoyBand.set_job_instigator(pre_whodunnit)
|
156
167
|
clear_job(job_hash)
|
168
|
+
@speed = nil
|
157
169
|
rescue Resque::TermException
|
158
170
|
Resque.enqueue(self, *args)
|
159
171
|
end
|
@@ -176,14 +188,14 @@ module BoyBand
|
|
176
188
|
idx = Resque.size(queue)
|
177
189
|
idx.times do |i|
|
178
190
|
item = Resque.peek(queue, i)
|
179
|
-
if item['args'] && item['args'][-1].match(/^chain::/)
|
191
|
+
if item && item['args'] && item['args'][-1].match(/^chain::/)
|
180
192
|
chain = item['args'].pop
|
181
193
|
end
|
182
|
-
if item['args'] && item['args'][-1].match(/^domain::/)
|
194
|
+
if item && item['args'] && item['args'][-1].match(/^domain::/)
|
183
195
|
domain = item['args'].pop
|
184
196
|
item['domain_id'] = domain.split(/::/, 2)[1]
|
185
197
|
end
|
186
|
-
res << item
|
198
|
+
res << item if item
|
187
199
|
end
|
188
200
|
end
|
189
201
|
res
|
@@ -243,7 +255,7 @@ module BoyBand
|
|
243
255
|
list = []
|
244
256
|
idx.times do |i|
|
245
257
|
item = Resque.peek(queue, i)
|
246
|
-
if item['args'] && item['args'][2].is_a?(Hash) && item['args'][2]['method'] == method
|
258
|
+
if item && item['args'] && item['args'][2].is_a?(Hash) && item['args'][2]['method'] == method
|
247
259
|
list << item
|
248
260
|
puts item.to_json
|
249
261
|
end
|
@@ -261,9 +273,11 @@ module BoyBand
|
|
261
273
|
end
|
262
274
|
|
263
275
|
idx = queue_size(queue)
|
276
|
+
job_hash = args_copy.to_json
|
277
|
+
return true if Resque.redis.get("scheduled/#{klass.to_s}/#{method_name}/#{job_hash}") == "t"
|
264
278
|
return false if idx > 500 # big queues mustn't be searched this way
|
265
279
|
idx = Resque.size(queue)
|
266
|
-
queue_class = (queue ==
|
280
|
+
queue_class = (queue.to_s == 'slow' ? 'SlowWorker' : 'Worker')
|
267
281
|
if false
|
268
282
|
job_hash = args_copy.to_json
|
269
283
|
timestamps = JSON.parse(Resque.redis.hget('hashed_jobs', job_hash) || "[]")
|
@@ -402,18 +416,7 @@ module BoyBand
|
|
402
416
|
end
|
403
417
|
|
404
418
|
def schedule_once(method, *args)
|
405
|
-
|
406
|
-
already_scheduled = Worker.scheduled?(self.class, :perform_action, {
|
407
|
-
'id' => id,
|
408
|
-
'method' => method,
|
409
|
-
'scheduled' => self.class.scheduled_stamp,
|
410
|
-
'arguments' => args
|
411
|
-
})
|
412
|
-
if !already_scheduled
|
413
|
-
schedule(method, *args)
|
414
|
-
else
|
415
|
-
false
|
416
|
-
end
|
419
|
+
schedule_once_for('default', method, *args)
|
417
420
|
end
|
418
421
|
|
419
422
|
def schedule_once_for(queue, method, *args)
|
@@ -464,17 +467,7 @@ module BoyBand
|
|
464
467
|
end
|
465
468
|
|
466
469
|
def schedule_once(method, *args)
|
467
|
-
|
468
|
-
already_scheduled = Worker.scheduled?(self, :perform_action, {
|
469
|
-
'method' => method,
|
470
|
-
'scheduled' => self.scheduled_stamp,
|
471
|
-
'arguments' => args
|
472
|
-
})
|
473
|
-
if !already_scheduled
|
474
|
-
schedule(method, *args)
|
475
|
-
else
|
476
|
-
false
|
477
|
-
end
|
470
|
+
schedule_once_for('default', method, *args)
|
478
471
|
end
|
479
472
|
|
480
473
|
def schedule_once_for(queue, method, *args)
|
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.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Whitmer
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -66,7 +66,7 @@ homepage: http://github.com/CoughDrop/boy_band
|
|
66
66
|
licenses:
|
67
67
|
- MIT
|
68
68
|
metadata: {}
|
69
|
-
post_install_message:
|
69
|
+
post_install_message:
|
70
70
|
rdoc_options: []
|
71
71
|
require_paths:
|
72
72
|
- lib
|
@@ -81,9 +81,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
requirements: []
|
84
|
-
|
85
|
-
|
86
|
-
signing_key:
|
84
|
+
rubygems_version: 3.0.8
|
85
|
+
signing_key:
|
87
86
|
specification_version: 4
|
88
87
|
summary: BoyBand
|
89
88
|
test_files: []
|