boy_band 0.1.10 → 0.1.11
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 +11 -24
- 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: 6931c59174a8d6eda05b764b143c11c38532c46ae0d68f41b35700539db6e45a
|
|
4
|
+
data.tar.gz: 7df882de888ee4ac4680d37006f437d5b26e9055f193f596486f6259bb75997e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2c19f3dd8e840f87b903d97450adbbfe0ce92b236cbbdec0905b7e6f18c283dcf2dccc2372f731cfbcc53bde6e530e79061b6da072b1cf49f61fe1ab461daeb4
|
|
7
|
+
data.tar.gz: 41cbb91e46bc9dcb8169c95c5b0b458626692679fa21668a09281d2f4a40568c7595917f8ac35268612c674470ea09bda8c557c85ba931a475bfd068dd22167a
|
data/lib/boy_band.rb
CHANGED
|
@@ -63,7 +63,12 @@ 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
|
-
|
|
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('+')}")
|
|
67
72
|
Rails.logger.warn("jobchain set, #{chain[0]} #{chain.join('##')}") if chain.length > 2
|
|
68
73
|
if chain.length > 5
|
|
69
74
|
Rails.logger.error("jobchain too deep: #{chain[0]}, #{chain.length} entries")
|
|
@@ -134,6 +139,7 @@ module BoyBand
|
|
|
134
139
|
klass = Object.const_get(klass_string)
|
|
135
140
|
method_name = args_copy.shift
|
|
136
141
|
job_hash = Digest::MD5.hexdigest(args_copy.to_json)
|
|
142
|
+
Resque.redis.del("scheduled/#{klass_string}/#{method_name}/#{job_hash}")
|
|
137
143
|
hash = args_copy[0] if args_copy[0].is_a?(Hash)
|
|
138
144
|
hash ||= {'method' => method_name}
|
|
139
145
|
action = "#{klass_string} . #{hash['method']} (#{hash['id']})"
|
|
@@ -261,6 +267,8 @@ module BoyBand
|
|
|
261
267
|
end
|
|
262
268
|
|
|
263
269
|
idx = queue_size(queue)
|
|
270
|
+
job_hash = args_copy.to_json
|
|
271
|
+
return true if Resque.redis.get("scheduled/#{klass.to_s}/#{method_name}/#{job_hash}") == "t"
|
|
264
272
|
return false if idx > 500 # big queues mustn't be searched this way
|
|
265
273
|
idx = Resque.size(queue)
|
|
266
274
|
queue_class = (queue == :slow ? 'SlowWorker' : 'Worker')
|
|
@@ -402,18 +410,7 @@ module BoyBand
|
|
|
402
410
|
end
|
|
403
411
|
|
|
404
412
|
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
|
|
413
|
+
schedule_once_for('default', method, *args)
|
|
417
414
|
end
|
|
418
415
|
|
|
419
416
|
def schedule_once_for(queue, method, *args)
|
|
@@ -464,17 +461,7 @@ module BoyBand
|
|
|
464
461
|
end
|
|
465
462
|
|
|
466
463
|
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
|
|
464
|
+
schedule_once_for('default', method, *args)
|
|
478
465
|
end
|
|
479
466
|
|
|
480
467
|
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.11
|
|
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-
|
|
11
|
+
date: 2020-05-31 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|