sidekiq-debouncer 2.0.1 → 2.0.2

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: 78b258ab5ad21facbcf96f6aab96f30e38542ea24a7c5fd9e23ee99057b67e6d
4
- data.tar.gz: 19db1ba7e392a4de9dcedfa8e236b8e8e334d7de56e71d8241aeb4e2d20b5e0a
3
+ metadata.gz: bab3413954e727ee13bc4d216f13621d1337df24f1ed970ecf146fae30501ef6
4
+ data.tar.gz: 883a815a2bb23e08abb175bf04f0231e028684d174c3d60bef6cc1450294764d
5
5
  SHA512:
6
- metadata.gz: 4c30876a9db412ee65a844c966fec6b4f2c84e33f5eb0393773c7db0ad9fd5d6c394b4c9a2f01e31178c93dcc5d5443e829e03f90a9c1db81814f594153af290
7
- data.tar.gz: 44e2d19a313ca3d07daaed130a9fb8a21721a6e6ed17756ed21028017096dd528d6b6a2d482a624095822c23158a9777620ae6dbeb0e541b8e2c7acebd003f68
6
+ metadata.gz: 254b6d10c2cf611d91e6971f9e21cc76964600ab951f718c88aa0d7eacb38fe3fccc4bd4f0e0f971d33e829e5a6ce0997d5c1a7a9886bc95e503a554b57e0241
7
+ data.tar.gz: 8d5877eec61fb2dbac4305db1815afc320306e0c1af78a872468a5a2218dd48f4b9f8a954e323e59aa3d088b783ae61cc14140a987c3f0785c80a3621c0dcbf7
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## Unreleased
2
+
3
+ ## [2.0.2] - 2023-03-13
4
+ - support Sidekiq::Testing
5
+
1
6
  ## [2.0.1] - 2023-03-04
2
7
  - don't remove debounce key in redis to avoid invalid debouncing
3
8
 
data/README.md CHANGED
@@ -103,6 +103,15 @@ end
103
103
 
104
104
  In order to test the behavior of `sidekiq-debouncer` it is necessary to disable testing mode. It is the limitation of internal implementation.
105
105
 
106
+ Sidekiq::Debouncer will not debounce the jobs in testing mode, instead they'll be executed like normal jobs (pushed to fake queue or executed inline depending on settings).
107
+ Server middleware needs to be added to `Sidekiq::Testing` chain:
108
+
109
+ ```ruby
110
+ Sidekiq::Testing.server_middleware do |chain|
111
+ chain.add Sidekiq::Debouncer::Middleware::Server
112
+ end
113
+ ```
114
+
106
115
  ## License
107
116
 
108
117
  MIT Licensed. See LICENSE.txt for details.
@@ -28,9 +28,6 @@ module Sidekiq
28
28
  return job if !klass.get_sidekiq_options["debounce"] || job["debounce_key"]
29
29
 
30
30
  debounce(klass, job)
31
-
32
- # prevent normal sidekiq flow
33
- false
34
31
  end
35
32
 
36
33
  private
@@ -46,9 +43,14 @@ module Sidekiq
46
43
  job["args"] = [job["args"]]
47
44
  job.delete("debounce")
48
45
 
46
+ return job if testing?
47
+
49
48
  redis do |connection|
50
49
  redis_debounce(connection, keys: ["schedule", key], argv: [Sidekiq.dump_json(job), time, @debounce_key_ttl])
51
50
  end
51
+
52
+ # prevent normal sidekiq flow
53
+ false
52
54
  end
53
55
 
54
56
  def debounce_key(klass, job, options)
@@ -79,6 +81,10 @@ module Sidekiq
79
81
  retry
80
82
  end
81
83
  end
84
+
85
+ def testing?
86
+ defined?(Sidekiq::Testing) && Sidekiq::Testing.enabled?
87
+ end
82
88
  end
83
89
  end
84
90
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sidekiq
4
4
  module Debouncer
5
- VERSION = "2.0.1"
5
+ VERSION = "2.0.2"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-debouncer
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastian Zuchmański
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-03-04 00:00:00.000000000 Z
12
+ date: 2023-03-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sidekiq