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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 90a8227c24d8deeb0fba498f2cadeacefe4b61ef
4
- data.tar.gz: fc44bea97f1765639572218b2249ec63cc9c6812
2
+ SHA256:
3
+ metadata.gz: ca39b386ec04e2a0405fc05051deec8b5e5ae715b366ee5d05f2c84bb3e39176
4
+ data.tar.gz: 8bff1c8634116b623a65f12cbf783d0814356d0c349f44233cc841272bbd70c3
5
5
  SHA512:
6
- metadata.gz: 7b687be320d795f79cfc8d7f23f6973fca2b7e4b9a45126098adc4d37826ae5ac3670b886ddbdece53aa06328473de170e55dbae6aa094dcd7620acd5b24f33d
7
- data.tar.gz: 00465321bf6afaf929d15d8d6209c6cf98eee79af2f6d78b6814f5967bf8807b7ca30e0dadbc331b01ad2ae9a5c1fa389207a6ff36fa2c00b8cc1abb9d244a3c
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
- => "OK"
42
+ => true
43
43
  Resque.enqueue UpdateCat, 1
44
- => "EXISTED"
44
+ => nil
45
45
  Resque.enqueue UpdateCat, 1
46
- => "EXISTED"
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
+ ```
@@ -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
@@ -60,8 +60,12 @@ module ResqueSolo
60
60
  end
61
61
 
62
62
  def cleanup(queue)
63
- keys = redis.keys("solo:queue:#{queue}:job:*")
64
- redis.del(*keys) if keys.any?
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
@@ -1,3 +1,3 @@
1
1
  module ResqueSolo
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
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.3.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: 2016-08-19 00:00:00.000000000 Z
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: '11.2'
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: '11.2'
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.0.0
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.6.6
118
+ rubygems_version: 2.7.6
119
119
  signing_key:
120
120
  specification_version: 4
121
121
  summary: Resque plugin to add unique jobs