sidekiq-throttled 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.adoc +3 -3
- data/lib/sidekiq/throttled/message.rb +32 -0
- data/lib/sidekiq/throttled/middlewares/server.rb +5 -5
- data/lib/sidekiq/throttled/version.rb +1 -1
- data/lib/sidekiq/throttled.rb +5 -7
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7746a966e9feb8f571468c3f9f790b618faacdb6a6b405183acce7afc9210fb0
|
4
|
+
data.tar.gz: 7b4a320e9ed8bab632e7834f67015b6b377071c77ac0838cf2a2db662c34ec81
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed36a36f934b607f08c132db2296a02741d4fad2a4436f4c475bc66f6a0cda49ece9e95782092603e4a3146de4c9b4dc7eec95223d4ba15a3c92715d861a2c91
|
7
|
+
data.tar.gz: c99428f6499ddcc70d89c9b73c8dcbcae275a6a81533645dcc7d8d0d0a7f04492b876afb4d651a934e5df2ad82996925b1f551ff16a9309beba99a146c0726f9
|
data/README.adoc
CHANGED
@@ -310,9 +310,9 @@ And the following Sidekiq Pro versions:
|
|
310
310
|
|
311
311
|
=== Sidekiq-Pro
|
312
312
|
|
313
|
-
If you're working on Sidekiq-Pro support make sure
|
314
|
-
|
315
|
-
|
313
|
+
If you're working on Sidekiq-Pro support make sure that you have Sidekiq-Pro
|
314
|
+
license set either in the global config, or in `BUNDLE_GEMS\__CONTRIBSYS__COM`
|
315
|
+
environment variable.
|
316
316
|
|
317
317
|
== Contributing
|
318
318
|
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sidekiq
|
4
|
+
module Throttled
|
5
|
+
class Message
|
6
|
+
def initialize(item)
|
7
|
+
@item = item.is_a?(Hash) ? item : parse(item)
|
8
|
+
end
|
9
|
+
|
10
|
+
def job_class
|
11
|
+
@item.fetch("wrapped") { @item["class"] }
|
12
|
+
end
|
13
|
+
|
14
|
+
def job_args
|
15
|
+
@item.key?("wrapped") ? @item.dig("args", 0, "arguments") : @item["args"]
|
16
|
+
end
|
17
|
+
|
18
|
+
def job_id
|
19
|
+
@item["jid"]
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def parse(item)
|
25
|
+
item = Sidekiq.load_json(item)
|
26
|
+
item.is_a?(Hash) ? item : {}
|
27
|
+
rescue JSON::ParserError
|
28
|
+
{}
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# internal
|
4
|
+
require_relative "../message"
|
4
5
|
require_relative "../registry"
|
5
6
|
|
6
7
|
module Sidekiq
|
@@ -13,12 +14,11 @@ module Sidekiq
|
|
13
14
|
def call(_worker, msg, _queue)
|
14
15
|
yield
|
15
16
|
ensure
|
16
|
-
|
17
|
-
jid = msg["jid"]
|
17
|
+
message = Message.new(msg)
|
18
18
|
|
19
|
-
if
|
20
|
-
Registry.get
|
21
|
-
strategy.finalize!(
|
19
|
+
if message.job_class && message.job_id
|
20
|
+
Registry.get(message.job_class) do |strategy|
|
21
|
+
strategy.finalize!(message.job_id, *message.job_args)
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
data/lib/sidekiq/throttled.rb
CHANGED
@@ -5,6 +5,7 @@ require "sidekiq"
|
|
5
5
|
require_relative "./throttled/config"
|
6
6
|
require_relative "./throttled/cooldown"
|
7
7
|
require_relative "./throttled/job"
|
8
|
+
require_relative "./throttled/message"
|
8
9
|
require_relative "./throttled/middlewares/server"
|
9
10
|
require_relative "./throttled/patches/basic_fetch"
|
10
11
|
require_relative "./throttled/patches/super_fetch"
|
@@ -75,14 +76,11 @@ module Sidekiq
|
|
75
76
|
# @param [String] message Job's JSON payload
|
76
77
|
# @return [Boolean]
|
77
78
|
def throttled?(message)
|
78
|
-
message =
|
79
|
-
|
80
|
-
jid = message["jid"]
|
79
|
+
message = Message.new(message)
|
80
|
+
return false unless message.job_class && message.job_id
|
81
81
|
|
82
|
-
|
83
|
-
|
84
|
-
Registry.get(job) do |strategy|
|
85
|
-
return strategy.throttled?(jid, *message["args"])
|
82
|
+
Registry.get(message.job_class) do |strategy|
|
83
|
+
return strategy.throttled?(message.job_id, *message.job_args)
|
86
84
|
end
|
87
85
|
|
88
86
|
false
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidekiq-throttled
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexey Zapparov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-04-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -67,6 +67,7 @@ files:
|
|
67
67
|
- lib/sidekiq/throttled/errors.rb
|
68
68
|
- lib/sidekiq/throttled/expirable_set.rb
|
69
69
|
- lib/sidekiq/throttled/job.rb
|
70
|
+
- lib/sidekiq/throttled/message.rb
|
70
71
|
- lib/sidekiq/throttled/middlewares/server.rb
|
71
72
|
- lib/sidekiq/throttled/patches/basic_fetch.rb
|
72
73
|
- lib/sidekiq/throttled/patches/super_fetch.rb
|
@@ -89,9 +90,9 @@ licenses:
|
|
89
90
|
- MIT
|
90
91
|
metadata:
|
91
92
|
homepage_uri: https://github.com/ixti/sidekiq-throttled
|
92
|
-
source_code_uri: https://github.com/ixti/sidekiq-throttled/tree/v1.
|
93
|
+
source_code_uri: https://github.com/ixti/sidekiq-throttled/tree/v1.4.0
|
93
94
|
bug_tracker_uri: https://github.com/ixti/sidekiq-throttled/issues
|
94
|
-
changelog_uri: https://github.com/ixti/sidekiq-throttled/blob/v1.
|
95
|
+
changelog_uri: https://github.com/ixti/sidekiq-throttled/blob/v1.4.0/CHANGES.md
|
95
96
|
rubygems_mfa_required: 'true'
|
96
97
|
post_install_message:
|
97
98
|
rdoc_options: []
|