sidekiq-superworker 1.1.0 → 1.2.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
2
  SHA1:
3
- metadata.gz: a30dd0e4575bf141b1aa0c262df3d08fb21a7745
4
- data.tar.gz: a6ca0500b339d3c5f75400c9efb58bfbacab5bfe
3
+ metadata.gz: ae27a81adaff0c4d2eb72b1f95dab8c5c25a7260
4
+ data.tar.gz: 187c3f3729c27a7ddfbc3019f94743e0893e9c59
5
5
  SHA512:
6
- metadata.gz: 7bb2bc65a5e482cfec52dd8d23a1df3209bb9688d79449e573857076cc2442e5ef17a7769813b437cf4af3d42f4a6057f207b254b604ce16dbc2db41ceb19ecd
7
- data.tar.gz: a2d9bff3ed22aa146080cb180acc007aaae88261af333b399cf56f8129d467cd9304e15d8449218949072ea69d542c573c749e6d783c259afa9572e97095f8cd
6
+ metadata.gz: d1702fea0b8f47b6ff3b69875c2be6130ca4fb0b03e371b57c3e56adcbb92d207e8cf23641df213ca6e57231ac28122bc773593fd7b688805ac1635849176b35
7
+ data.tar.gz: 866911be02c68203d7b73892d8ce3a13be9046be106fc56e76b968e249b7f83bc0a1efe11be1abc93d7355364752aeef60da6989efd613e7f7c51e6c973c7209
data/README.md CHANGED
@@ -136,6 +136,15 @@ When a superjob is queued, records for all of its subjobs are created. By defaul
136
136
  Sidekiq::Superworker.options[:delete_subjobs_after_superjob_completes] = false
137
137
  ```
138
138
 
139
+ #### Superjob expiration
140
+
141
+ When a subjob dies due to too many retries, the jobs that depend on it will never run and the superjob will never be completed. Consequently, the subjob Redis keys will never be removed. You can set `superjob_expiration` to *N* to make the subjobs keys expire in *N* seconds. The default value is `nil` (the keys will never expire).
142
+
143
+ ```ruby
144
+ # config/initializers/superworker.rb
145
+ Sidekiq::Superworker.options[:superjob_expiration] = 2592000 # 1 Month
146
+ ```
147
+
139
148
  ### Logging
140
149
 
141
150
  To make debugging easier, Sidekiq Superworker provides detailed log messages when its logger is set to the DEBUG level:
@@ -9,7 +9,8 @@ module Sidekiq
9
9
  module Superworker
10
10
  DEFAULTS = {
11
11
  delete_subjobs_after_superjob_completes: true,
12
- subjob_redis_prefix: 'subjob'
12
+ subjob_redis_prefix: 'subjob',
13
+ superjob_expiration: nil
13
14
  }
14
15
 
15
16
  def self.options
@@ -74,7 +74,7 @@ module Sidekiq
74
74
  result = nil
75
75
  Sidekiq.redis do |conn|
76
76
  conn.multi do
77
- result = yield
77
+ result = yield(conn)
78
78
  end
79
79
  end
80
80
  result
@@ -102,8 +102,10 @@ module Sidekiq
102
102
 
103
103
  def save
104
104
  return false unless self.valid?
105
- Sidekiq.redis do |conn|
105
+
106
+ self.class.transaction do |conn|
106
107
  conn.mapped_hmset(key, to_param)
108
+ conn.expire(key,Superworker.options[:superjob_expiration]) if Superworker.options[:superjob_expiration]
107
109
  end
108
110
  true
109
111
  end
@@ -140,12 +142,12 @@ module Sidekiq
140
142
 
141
143
  def children
142
144
  return [] if children_ids.blank?
143
- children = children_ids.collect { |id| self.class.find_by_jid(self.class.jid(superjob_id,id)) }
145
+ children = children_ids.collect { |id| self.class.find_by_jid(self.class.jid(superjob_id, id)) }
144
146
  children.reject(&:nil?)
145
147
  end
146
148
 
147
149
  def next
148
- self.class.find_by_jid(self.class.jid(superjob_id,next_id))
150
+ self.class.find_by_jid(self.class.jid(superjob_id, next_id))
149
151
  end
150
152
 
151
153
  def ==(other)
@@ -1,5 +1,5 @@
1
1
  module Sidekiq
2
2
  module Superworker
3
- VERSION = '1.1.0'
3
+ VERSION = '1.2.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-superworker
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Benner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-08 00:00:00.000000000 Z
11
+ date: 2015-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sidekiq