resque_solo 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +15 -3
- data/lib/resque_ext/resque.rb +19 -0
- data/lib/resque_solo/queue.rb +6 -2
- data/lib/resque_solo/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ca39b386ec04e2a0405fc05051deec8b5e5ae715b366ee5d05f2c84bb3e39176
|
4
|
+
data.tar.gz: 8bff1c8634116b623a65f12cbf783d0814356d0c349f44233cc841272bbd70c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4cfd41a2ed021f4e4a4bcd94f80b683086d29a28d20c00d914990ede0afcdb05c5cb8dfa0d93785de3a1aac506e14607386731a8aa34b4f54d940dd6adc3de9c
|
7
|
+
data.tar.gz: d5eb65fbed46481fc820f212f75774bd43f8b8cd4070146eb332e3b33b695a254c4c11a3cd4165d9fde3c6642d7f17ebab4ffc66fdc7743516991c0fd55a7d33
|
data/README.md
CHANGED
@@ -39,11 +39,11 @@ If you attempt to queue a unique job multiple times, it is ignored:
|
|
39
39
|
|
40
40
|
```
|
41
41
|
Resque.enqueue UpdateCat, 1
|
42
|
-
=>
|
42
|
+
=> true
|
43
43
|
Resque.enqueue UpdateCat, 1
|
44
|
-
=>
|
44
|
+
=> nil
|
45
45
|
Resque.enqueue UpdateCat, 1
|
46
|
-
=>
|
46
|
+
=> nil
|
47
47
|
Resque.size :cats
|
48
48
|
=> 1
|
49
49
|
Resque.enqueued? UpdateCat, 1
|
@@ -64,3 +64,15 @@ The `lock_after_execution_period` setting can be used to delay when the unique j
|
|
64
64
|
takes around 10 seconds, and you don't want to requeue another job until you are sure it is done,
|
65
65
|
you could set `lock_after_execution_period = 20`. Or if you never want to run a long running
|
66
66
|
job more than once per minute, set `lock_after_execution_period = 60`.
|
67
|
+
|
68
|
+
```ruby
|
69
|
+
class UpdateCat
|
70
|
+
include Resque::Plugins::UniqueJob
|
71
|
+
@queue = :cats
|
72
|
+
@lock_after_execution_period = 20
|
73
|
+
|
74
|
+
def self.perform(cat_id)
|
75
|
+
# do something
|
76
|
+
end
|
77
|
+
end
|
78
|
+
```
|
data/lib/resque_ext/resque.rb
CHANGED
@@ -1,5 +1,24 @@
|
|
1
1
|
module Resque
|
2
2
|
class << self
|
3
|
+
# Override
|
4
|
+
# https://github.com/resque/resque/blob/master/lib/resque.rb
|
5
|
+
def enqueue_to(queue, klass, *args)
|
6
|
+
# Perform before_enqueue hooks. Don't perform enqueue if any hook returns false
|
7
|
+
before_hooks = Plugin.before_enqueue_hooks(klass).collect do |hook|
|
8
|
+
klass.send(hook, *args)
|
9
|
+
end
|
10
|
+
return nil if before_hooks.any? { |result| result == false }
|
11
|
+
|
12
|
+
result = Job.create(queue, klass, *args)
|
13
|
+
return nil if result == "EXISTED"
|
14
|
+
|
15
|
+
Plugin.after_enqueue_hooks(klass).each do |hook|
|
16
|
+
klass.send(hook, *args)
|
17
|
+
end
|
18
|
+
|
19
|
+
true
|
20
|
+
end
|
21
|
+
|
3
22
|
def enqueued?(klass, *args)
|
4
23
|
enqueued_in?(queue_from_class(klass), klass, *args)
|
5
24
|
end
|
data/lib/resque_solo/queue.rb
CHANGED
@@ -60,8 +60,12 @@ module ResqueSolo
|
|
60
60
|
end
|
61
61
|
|
62
62
|
def cleanup(queue)
|
63
|
-
|
64
|
-
|
63
|
+
cursor = "0"
|
64
|
+
loop do
|
65
|
+
cursor, keys = redis.scan(cursor, match: "solo:queue:#{queue}:job:*")
|
66
|
+
redis.del(*keys) if keys.any?
|
67
|
+
break if cursor.to_i.zero?
|
68
|
+
end
|
65
69
|
end
|
66
70
|
|
67
71
|
private
|
data/lib/resque_solo/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: resque_solo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tee Parham
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: resque
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '12.0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '12.0'
|
83
83
|
description: Resque plugin to add unique jobs
|
84
84
|
email:
|
85
85
|
- tee@neighborland.com
|
@@ -107,7 +107,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
107
107
|
requirements:
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 2.
|
110
|
+
version: 2.2.2
|
111
111
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
112
|
requirements:
|
113
113
|
- - ">="
|
@@ -115,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
115
115
|
version: '0'
|
116
116
|
requirements: []
|
117
117
|
rubyforge_project:
|
118
|
-
rubygems_version: 2.
|
118
|
+
rubygems_version: 2.7.6
|
119
119
|
signing_key:
|
120
120
|
specification_version: 4
|
121
121
|
summary: Resque plugin to add unique jobs
|