sidekiq-antidote 1.0.0 → 1.2.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 +61 -23
- data/lib/sidekiq/antidote/class_qualifier.rb +6 -5
- data/lib/sidekiq/antidote/inhibitor.rb +0 -4
- data/lib/sidekiq/antidote/middlewares/client.rb +2 -2
- data/lib/sidekiq/antidote/middlewares/server.rb +2 -2
- data/lib/sidekiq/antidote/middlewares/shared.rb +12 -2
- data/lib/sidekiq/antidote/remedy.rb +3 -4
- data/lib/sidekiq/antidote/version.rb +1 -1
- data/web/locales/en.yml +1 -1
- data/web/views/add.html.erb +3 -3
- data/web/views/index.html.erb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dce4fd5b1e9e0062569e3cc9d2febc7a699f9cceaa2f738114f6555dfeea38bb
|
4
|
+
data.tar.gz: 3ed45d2c929f9749b2a6e9f5d7257f419de569ca0cb7bb306a9e21c98b2efc1a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b86b69872c145890c4656a4c4c84d15cc14002e10ea6300120ddb42400fc3e4d0979f177622b9785311d2ff86e78859d7bf37600d3135b93874611e79ab17037
|
7
|
+
data.tar.gz: c6f79bd8ac0d37c5a704d091b01bddc06f564553f441ae38198b12c50899cfceed4eda2cfc8d9045748182623484f07b0224336d9a6ea17d184f65f98461beba
|
data/README.adoc
CHANGED
@@ -52,6 +52,41 @@ require "sidekiq/web"
|
|
52
52
|
require "sidekiq/antidote/web"
|
53
53
|
----
|
54
54
|
|
55
|
+
=== Middleware(s)
|
56
|
+
|
57
|
+
`Sidekiq::Antidote` relies on following bundled middlewares:
|
58
|
+
|
59
|
+
* `Sidekiq::Antidote::Middlewares::Client`
|
60
|
+
* `Sidekiq::Antidote::Middlewares::Server`
|
61
|
+
|
62
|
+
The middleware is automatically injected when you require `sidekiq/antidote`.
|
63
|
+
In rare cases, when this causes an issue, you can change middleware order manually:
|
64
|
+
|
65
|
+
[source,ruby]
|
66
|
+
----
|
67
|
+
Sidekiq.configure_client do |config|
|
68
|
+
# ...
|
69
|
+
|
70
|
+
config.client_middleware do |chain|
|
71
|
+
chain.prepend(Sidekiq::Antidote::Middlewares::Client)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
Sidekiq.configure_server do |config|
|
76
|
+
# ...
|
77
|
+
|
78
|
+
config.client_middleware do |chain|
|
79
|
+
chain.prepend(Sidekiq::Antidote::Middlewares::Client)
|
80
|
+
end
|
81
|
+
|
82
|
+
config.server_middleware do |chain|
|
83
|
+
chain.prepend(Sidekiq::Antidote::Middlewares::Server)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
----
|
87
|
+
|
88
|
+
See: https://github.com/sidekiq/sidekiq/blob/main/lib/sidekiq/middleware/chain.rb
|
89
|
+
|
55
90
|
|
56
91
|
== Inhibitors
|
57
92
|
|
@@ -65,10 +100,10 @@ kill::
|
|
65
100
|
Kill the job (send to the dead set instead of enqueueing and/or performing)
|
66
101
|
|
67
102
|
|
68
|
-
===
|
103
|
+
=== Class Qualifiers
|
69
104
|
|
70
|
-
|
71
|
-
and method name (when used with ActionMailer delayed deliveries):
|
105
|
+
Class qualifier is the job class pattern. It may match the job class or the job
|
106
|
+
class and method name (when used with ActionMailer delayed deliveries):
|
72
107
|
|
73
108
|
* `ExampleJob`
|
74
109
|
* `Namespaced::ExampleJob`
|
@@ -90,35 +125,38 @@ You can also use pattern matching:
|
|
90
125
|
* `{A,B,C}Job` matches `AJob`, `BJob`, and `CJob`
|
91
126
|
|
92
127
|
|
93
|
-
==
|
128
|
+
== Compatibility
|
94
129
|
|
95
|
-
This library aims to support and is tested against
|
130
|
+
This library aims to support and is tested against:
|
96
131
|
|
97
|
-
*
|
98
|
-
|
99
|
-
|
132
|
+
* https://www.ruby-lang.org[Ruby]
|
133
|
+
** MRI 3.0.x
|
134
|
+
** MRI 3.1.x
|
135
|
+
** MRI 3.2.x
|
136
|
+
** MRI 3.3.x
|
137
|
+
** MRI 3.4.x
|
138
|
+
* https://github.com/sidekiq/sidekiq[Sidekiq]
|
139
|
+
** 7.2.x
|
140
|
+
** 7.3.x
|
141
|
+
* https://redis.io[Redis]
|
142
|
+
** 7.0.x
|
143
|
+
** 7.2.x
|
100
144
|
|
101
145
|
If something doesn't work on one of these versions, it's a bug.
|
102
146
|
|
103
|
-
This library may inadvertently work (or seem to work) on other Ruby
|
104
|
-
however support will only be provided for the versions listed
|
147
|
+
This library may inadvertently work (or seem to work) on other Ruby, Redis, and
|
148
|
+
Sidekiq versions, however support will only be provided for the versions listed
|
149
|
+
above.
|
105
150
|
|
106
|
-
If you would like this library to support another Ruby
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
151
|
+
If you would like this library to support another Ruby, Redis, or Sidekiq
|
152
|
+
version, you may volunteer to be a maintainer. Being a maintainer entails making
|
153
|
+
sure all tests run and pass on that implementation. When something breaks on
|
154
|
+
your implementation, you will be responsible for providing patches in a timely
|
155
|
+
fashion. If critical issues for a particular implementation exist at the time of
|
156
|
+
a major release, support for that Ruby, Redis, and/or Sidekiq version may be
|
112
157
|
dropped.
|
113
158
|
|
114
159
|
|
115
|
-
== Supported Sidekiq Versions
|
116
|
-
|
117
|
-
This library aims to support and work with following Sidekiq versions:
|
118
|
-
|
119
|
-
* Sidekiq 7.2.x
|
120
|
-
|
121
|
-
|
122
160
|
== Development
|
123
161
|
|
124
162
|
bundle install
|
@@ -36,11 +36,6 @@ module Sidekiq
|
|
36
36
|
# @return [Regexp]
|
37
37
|
attr_reader :regexp
|
38
38
|
|
39
|
-
# @!method match?(job_class)
|
40
|
-
# @param job_class [String]
|
41
|
-
# @return [Boolean]
|
42
|
-
def_delegator :regexp, :match?
|
43
|
-
|
44
39
|
# @param pattern [#to_s]
|
45
40
|
def initialize(pattern)
|
46
41
|
@pattern = pattern.to_s.strip.freeze
|
@@ -51,6 +46,12 @@ module Sidekiq
|
|
51
46
|
freeze
|
52
47
|
end
|
53
48
|
|
49
|
+
# @param job_class [String, Class]
|
50
|
+
# @return [Boolean]
|
51
|
+
def match?(job_class)
|
52
|
+
regexp.match?(job_class.to_s)
|
53
|
+
end
|
54
|
+
|
54
55
|
# @param other [Object]
|
55
56
|
# @return [Boolean]
|
56
57
|
def eql?(other)
|
@@ -11,8 +11,8 @@ module Sidekiq
|
|
11
11
|
|
12
12
|
# @see https://github.com/sidekiq/sidekiq/wiki/Middleware
|
13
13
|
# @see https://github.com/sidekiq/sidekiq/wiki/Job-Format
|
14
|
-
def call(_, job_payload,
|
15
|
-
yield unless inhibit(job_payload)
|
14
|
+
def call(_, job_payload, queue_name, _)
|
15
|
+
yield unless inhibit(job_payload, queue_name)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
@@ -11,8 +11,8 @@ module Sidekiq
|
|
11
11
|
|
12
12
|
# @see https://github.com/sidekiq/sidekiq/wiki/Middleware
|
13
13
|
# @see https://github.com/sidekiq/sidekiq/wiki/Job-Format
|
14
|
-
def call(_, job_payload,
|
15
|
-
yield unless inhibit(job_payload)
|
14
|
+
def call(_, job_payload, queue_name)
|
15
|
+
yield unless inhibit(job_payload, queue_name)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
@@ -10,17 +10,27 @@ module Sidekiq
|
|
10
10
|
|
11
11
|
# @return [true] if message was inhibited
|
12
12
|
# @return [false] otherwise
|
13
|
-
def inhibit(message)
|
13
|
+
def inhibit(message, queue_name)
|
14
14
|
job_record = Sidekiq::JobRecord.new(message)
|
15
15
|
inhibitor = Antidote.remedy_for(job_record)
|
16
16
|
return false unless inhibitor
|
17
17
|
|
18
18
|
Antidote.log(:warn) { "I've got a poison! -- #{job_record.display_class}" }
|
19
19
|
Antidote.log(:warn) { "I've got a remedy! -- #{inhibitor}" }
|
20
|
-
|
20
|
+
|
21
|
+
apply_treatment(inhibitor, job_record, queue_name)
|
21
22
|
|
22
23
|
true
|
23
24
|
end
|
25
|
+
|
26
|
+
def apply_treatment(inhibitor, job_record, queue_name)
|
27
|
+
# Ensure message has queue name
|
28
|
+
message = Sidekiq.dump_json(job_record.item.merge({ "queue" => queue_name }))
|
29
|
+
|
30
|
+
case inhibitor.treatment
|
31
|
+
when "kill" then DeadSet.new.kill(message)
|
32
|
+
end
|
33
|
+
end
|
24
34
|
end
|
25
35
|
end
|
26
36
|
end
|
@@ -13,9 +13,8 @@ module Sidekiq
|
|
13
13
|
# @param refresh_rate [Float]
|
14
14
|
# @param repository [Repository]
|
15
15
|
def initialize(refresh_rate, repository:)
|
16
|
-
@
|
17
|
-
|
18
|
-
@inhibitors = repository.to_a.freeze
|
16
|
+
@refresher = Concurrent::TimerTask.new(execution_interval: refresh_rate, run_now: true) do
|
17
|
+
repository.to_a.freeze
|
19
18
|
end
|
20
19
|
end
|
21
20
|
|
@@ -30,7 +29,7 @@ module Sidekiq
|
|
30
29
|
return to_enum __method__ unless block
|
31
30
|
|
32
31
|
start_refresher unless refresher_running?
|
33
|
-
@
|
32
|
+
@refresher.value&.each(&block)
|
34
33
|
|
35
34
|
self
|
36
35
|
end
|
data/web/locales/en.yml
CHANGED
data/web/views/add.html.erb
CHANGED
@@ -25,11 +25,11 @@
|
|
25
25
|
</div>
|
26
26
|
</div>
|
27
27
|
<div class="form-group <%= "has-error" if @class_qualifier_error %>">
|
28
|
-
<label class="col-sm-2 control-label"><%= t("antidote.
|
28
|
+
<label class="col-sm-2 control-label"><%= t("antidote.class_qualifier") %></label>
|
29
29
|
<div class="col-sm-10">
|
30
|
-
<input id="antidote-inhibitor-qualifier" type="text" class="form-control <%= "is-invalid" if @class_qualifier_error %>" name="class_qualifier" value="<%= @class_qualifier %>">
|
30
|
+
<input id="antidote-inhibitor-class-qualifier" type="text" class="form-control <%= "is-invalid" if @class_qualifier_error %>" name="class_qualifier" value="<%= @class_qualifier %>">
|
31
31
|
<% if @class_qualifier_error %>
|
32
|
-
<div id="antidote-inhibitor-qualifier-error" class="help-block">
|
32
|
+
<div id="antidote-inhibitor-class-qualifier-error" class="help-block">
|
33
33
|
<strong>ERROR:</strong> <%= @class_qualifier_error %>
|
34
34
|
</div>
|
35
35
|
<% end %>
|
data/web/views/index.html.erb
CHANGED
@@ -12,7 +12,7 @@
|
|
12
12
|
<table class="antidote table table-hover table-bordered table-striped">
|
13
13
|
<thead>
|
14
14
|
<th><%= t("antidote.treatment") %></th>
|
15
|
-
<th><%= t("antidote.
|
15
|
+
<th><%= t("antidote.class_qualifier") %></th>
|
16
16
|
<th><%= t("antidote.actions") %></th>
|
17
17
|
</thead>
|
18
18
|
<tbody>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidekiq-antidote
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.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:
|
11
|
+
date: 2025-01-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -66,9 +66,9 @@ licenses:
|
|
66
66
|
- MIT
|
67
67
|
metadata:
|
68
68
|
homepage_uri: https://github.com/ixti/sidekiq-antidote
|
69
|
-
source_code_uri: https://github.com/ixti/sidekiq-antidote/tree/v1.
|
69
|
+
source_code_uri: https://github.com/ixti/sidekiq-antidote/tree/v1.2.0
|
70
70
|
bug_tracker_uri: https://github.com/ixti/sidekiq-antidote/issues
|
71
|
-
changelog_uri: https://github.com/ixti/sidekiq-antidote/blob/v1.
|
71
|
+
changelog_uri: https://github.com/ixti/sidekiq-antidote/blob/v1.2.0/CHANGES.md
|
72
72
|
rubygems_mfa_required: 'true'
|
73
73
|
post_install_message:
|
74
74
|
rdoc_options: []
|
@@ -85,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
85
|
- !ruby/object:Gem::Version
|
86
86
|
version: '0'
|
87
87
|
requirements: []
|
88
|
-
rubygems_version: 3.
|
88
|
+
rubygems_version: 3.5.22
|
89
89
|
signing_key:
|
90
90
|
specification_version: 4
|
91
91
|
summary: Sidekiq poison-pill instant remedy
|