sidekiq-batch 0.1.7 → 0.1.9

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
  SHA256:
3
- metadata.gz: 3d45a854229157eb70e9fb9b04390e6b4958fd535cb68d6dd2e0aab84c51e4b7
4
- data.tar.gz: b8ec67ac9cce0cafde5b70883c0a77794f0d8506b694f74fb79765dc0ae5d7f2
3
+ metadata.gz: b70659750dde1e5afc337c6d8694055af5e103718a3719e3e12bffd66dbe191f
4
+ data.tar.gz: c47488bb9c1a9115e3bc9ee006190d3dd52534006b8bd74184810885e0dbbfcd
5
5
  SHA512:
6
- metadata.gz: e703eb7d37c4234269835ee009d73cafd4bb9afb11d8c818860e18e7504244db08142830eeac20d32bff96079febcb13ae130fd7e0a21eadeea6115cb5384989
7
- data.tar.gz: e616deb4ed0f7599b9c09d1d0fd943f25131c89966ae0575b073c507053ac9012357ed07ac34456ba0f60d1a91ab7d75c337ffe6fb4e8aca6b21fe2aea2b1ea4
6
+ metadata.gz: afb196a979725830e0576d4d9f1756c7d3afba5298c46d22b575a9cfbab39fcefe19434f27fd80808d5082a92e127784eb543408e7848e50f5f78e962c5e66a6
7
+ data.tar.gz: 9cfd132e6beb024c493b6c8acbf7ea375604ed193575abc9ac64b6ee1c10e37992796f80f6441661d24efb9b55963b50e12959b56bb30bf6abb5de6226977125
@@ -0,0 +1,3 @@
1
+ # These are supported funding model platforms
2
+
3
+ open_collective: sidekiq-batch
@@ -0,0 +1,70 @@
1
+ # For most projects, this workflow file will not need changing; you simply need
2
+ # to commit it to your repository.
3
+ #
4
+ # You may wish to alter this file to override the set of languages analyzed,
5
+ # or to provide custom queries or build logic.
6
+ #
7
+ # ******** NOTE ********
8
+ # We have attempted to detect the languages in your repository. Please check
9
+ # the `language` matrix defined below to confirm you have the correct set of
10
+ # supported CodeQL languages.
11
+ #
12
+ name: "CodeQL"
13
+
14
+ on:
15
+ push:
16
+ branches: [ master ]
17
+ pull_request:
18
+ # The branches below must be a subset of the branches above
19
+ branches: [ master ]
20
+ schedule:
21
+ - cron: '24 3 * * 2'
22
+
23
+ jobs:
24
+ analyze:
25
+ name: Analyze
26
+ runs-on: ubuntu-latest
27
+ permissions:
28
+ actions: read
29
+ contents: read
30
+ security-events: write
31
+
32
+ strategy:
33
+ fail-fast: false
34
+ matrix:
35
+ language: [ 'ruby' ]
36
+ # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
37
+ # Learn more about CodeQL language support at https://git.io/codeql-language-support
38
+
39
+ steps:
40
+ - name: Checkout repository
41
+ uses: actions/checkout@v3
42
+
43
+ # Initializes the CodeQL tools for scanning.
44
+ - name: Initialize CodeQL
45
+ uses: github/codeql-action/init@v2
46
+ with:
47
+ languages: ${{ matrix.language }}
48
+ # If you wish to specify custom queries, you can do so here or in a config file.
49
+ # By default, queries listed here will override any specified in a config file.
50
+ # Prefix the list here with "+" to use these queries and those in the config file.
51
+ # queries: ./path/to/local/query, your-org/your-repo/queries@main
52
+
53
+ # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
54
+ # If this step fails, then you should remove it and run the build manually (see below)
55
+ - name: Autobuild
56
+ uses: github/codeql-action/autobuild@v2
57
+
58
+ # ℹ️ Command-line programs to run using the OS shell.
59
+ # 📚 https://git.io/JvXDl
60
+
61
+ # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
62
+ # and modify them (or add more) to build your code if your project
63
+ # uses a compiled language
64
+
65
+ #- run: |
66
+ # make bootstrap
67
+ # make release
68
+
69
+ - name: Perform CodeQL Analysis
70
+ uses: github/codeql-action/analyze@v2
@@ -40,10 +40,10 @@ module Sidekiq
40
40
 
41
41
  _, _, success, _, complete, pending, children, failure = Sidekiq.redis do |r|
42
42
  r.multi do |pipeline|
43
- pipeline.sadd("BID-#{parent_bid}-success", bid)
43
+ pipeline.sadd("BID-#{parent_bid}-success", [bid])
44
44
  pipeline.expire("BID-#{parent_bid}-success", Sidekiq::Batch::BID_EXPIRE_TTL)
45
45
  pipeline.scard("BID-#{parent_bid}-success")
46
- pipeline.sadd("BID-#{parent_bid}-complete", bid)
46
+ pipeline.sadd("BID-#{parent_bid}-complete", [bid])
47
47
  pipeline.scard("BID-#{parent_bid}-complete")
48
48
  pipeline.hincrby("BID-#{parent_bid}", "pending", 0)
49
49
  pipeline.hincrby("BID-#{parent_bid}", "children", 0)
@@ -81,7 +81,7 @@ module Sidekiq
81
81
  Sidekiq.logger.debug {"Finalize parent complete bid: #{parent_bid}"}
82
82
  _, complete, pending, children, failure = Sidekiq.redis do |r|
83
83
  r.multi do |pipeline|
84
- pipeline.sadd("BID-#{parent_bid}-complete", bid)
84
+ pipeline.sadd("BID-#{parent_bid}-complete", [bid])
85
85
  pipeline.scard("BID-#{parent_bid}-complete")
86
86
  pipeline.hincrby("BID-#{parent_bid}", "pending", 0)
87
87
  pipeline.hincrby("BID-#{parent_bid}", "children", 0)
@@ -1,5 +1,5 @@
1
1
  module Sidekiq
2
2
  class Batch
3
- VERSION = '0.1.7'.freeze
3
+ VERSION = '0.1.9'.freeze
4
4
  end
5
5
  end
data/lib/sidekiq/batch.rb CHANGED
@@ -43,10 +43,10 @@ module Sidekiq
43
43
  callback_key = "#{@bidkey}-callbacks-#{event}"
44
44
  Sidekiq.redis do |r|
45
45
  r.multi do |pipeline|
46
- pipeline.sadd(callback_key, JSON.unparse({
46
+ pipeline.sadd(callback_key, [JSON.unparse({
47
47
  callback: callback,
48
48
  opts: options
49
- }))
49
+ })])
50
50
  pipeline.expire(callback_key, BID_EXPIRE_TTL)
51
51
  end
52
52
  end
@@ -96,7 +96,7 @@ module Sidekiq
96
96
  pipeline.hincrby(@bidkey, "total", @ready_to_queue.size)
97
97
  pipeline.expire(@bidkey, BID_EXPIRE_TTL)
98
98
 
99
- pipeline.sadd(@bidkey + "-jids", @ready_to_queue)
99
+ pipeline.sadd(@bidkey + "-jids", [@ready_to_queue])
100
100
  pipeline.expire(@bidkey + "-jids", BID_EXPIRE_TTL)
101
101
  end
102
102
  end
@@ -149,7 +149,7 @@ module Sidekiq
149
149
  def process_failed_job(bid, jid)
150
150
  _, pending, failed, children, complete, parent_bid = Sidekiq.redis do |r|
151
151
  r.multi do |pipeline|
152
- pipeline.sadd("BID-#{bid}-failed", jid)
152
+ pipeline.sadd("BID-#{bid}-failed", [jid])
153
153
 
154
154
  pipeline.hincrby("BID-#{bid}", "pending", 0)
155
155
  pipeline.scard("BID-#{bid}-failed")
@@ -166,7 +166,7 @@ module Sidekiq
166
166
  Sidekiq.redis do |r|
167
167
  r.multi do |pipeline|
168
168
  pipeline.hincrby("BID-#{parent_bid}", "pending", 1)
169
- pipeline.sadd("BID-#{parent_bid}-failed", jid)
169
+ pipeline.sadd("BID-#{parent_bid}-failed", [jid])
170
170
  pipeline.expire("BID-#{parent_bid}-failed", BID_EXPIRE_TTL)
171
171
  end
172
172
  end
@@ -188,8 +188,8 @@ module Sidekiq
188
188
  pipeline.hget("BID-#{bid}", "total")
189
189
  pipeline.hget("BID-#{bid}", "parent_bid")
190
190
 
191
- pipeline.srem("BID-#{bid}-failed", jid)
192
- pipeline.srem("BID-#{bid}-jids", jid)
191
+ pipeline.srem("BID-#{bid}-failed", [jid])
192
+ pipeline.srem("BID-#{bid}-jids", [jid])
193
193
  pipeline.expire("BID-#{bid}", BID_EXPIRE_TTL)
194
194
  end
195
195
  end
@@ -203,12 +203,13 @@ module Sidekiq
203
203
  end
204
204
 
205
205
  def enqueue_callbacks(event, bid)
206
+ event_name = event.to_s
206
207
  batch_key = "BID-#{bid}"
207
- callback_key = "#{batch_key}-callbacks-#{event}"
208
+ callback_key = "#{batch_key}-callbacks-#{event_name}"
208
209
  already_processed, _, callbacks, queue, parent_bid, callback_batch = Sidekiq.redis do |r|
209
210
  r.multi do |pipeline|
210
- pipeline.hget(batch_key, event)
211
- pipeline.hset(batch_key, event, true)
211
+ pipeline.hget(batch_key, event_name)
212
+ pipeline.hset(batch_key, event_name, true)
212
213
  pipeline.smembers(callback_key)
213
214
  pipeline.hget(batch_key, "callback_queue")
214
215
  pipeline.hget(batch_key, "parent_bid")
@@ -222,10 +223,10 @@ module Sidekiq
222
223
  parent_bid = !parent_bid || parent_bid.empty? ? nil : parent_bid # Basically parent_bid.blank?
223
224
  callback_args = callbacks.reduce([]) do |memo, jcb|
224
225
  cb = Sidekiq.load_json(jcb)
225
- memo << [cb['callback'], event, cb['opts'], bid, parent_bid]
226
+ memo << [cb['callback'], event_name, cb['opts'], bid, parent_bid]
226
227
  end
227
228
 
228
- opts = {"bid" => bid, "event" => event}
229
+ opts = {"bid" => bid, "event" => event_name}
229
230
 
230
231
  # Run callback batch finalize synchronously
231
232
  if callback_batch
@@ -233,7 +234,7 @@ module Sidekiq
233
234
  # Pass in stored event as callback finalize is processed on complete event
234
235
  cb_opts = callback_args.first&.at(2) || opts
235
236
 
236
- Sidekiq.logger.debug {"Run callback batch bid: #{bid} event: #{event} args: #{callback_args.inspect}"}
237
+ Sidekiq.logger.debug {"Run callback batch bid: #{bid} event: #{event_name} args: #{callback_args.inspect}"}
237
238
  # Finalize now
238
239
  finalizer = Sidekiq::Batch::Callback::Finalize.new
239
240
  status = Status.new bid
@@ -242,7 +243,7 @@ module Sidekiq
242
243
  return
243
244
  end
244
245
 
245
- Sidekiq.logger.debug {"Enqueue callback bid: #{bid} event: #{event} args: #{callback_args.inspect}"}
246
+ Sidekiq.logger.debug {"Enqueue callback bid: #{bid} event: #{event_name} args: #{callback_args.inspect}"}
246
247
 
247
248
  if callback_args.empty?
248
249
  # Finalize now
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-batch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcin Naglik
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-03-13 00:00:00.000000000 Z
11
+ date: 2022-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sidekiq
@@ -87,8 +87,10 @@ executables: []
87
87
  extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
+ - ".github/FUNDING.yml"
90
91
  - ".github/dependabot.yml"
91
92
  - ".github/workflows/ci.yml"
93
+ - ".github/workflows/codeql-analysis.yml"
92
94
  - ".github/workflows/stale.yml"
93
95
  - ".gitignore"
94
96
  - ".rspec"