sidekiq-antidote 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.adoc +61 -23
- 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: 9f5bdf47fd299dc626c6fc0afb94896301c66e5b1f9f33875383375d0d5ac483
|
4
|
+
data.tar.gz: bb9966c063f7ca0325d31229c6f4d0cf445d53392bb89a201dba92891759ece3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87e30e47eb2e37cea51f9037469a4395651d49da8664558d893a71e83d7af275c32ea5ce2e6e8c6b6d464e979af684498972dd2a21c5ddedaf9fe73a2e4a1e62
|
7
|
+
data.tar.gz: ffea8f3beef24555534621992e60d18c3c3ec0ab3855e07a65e5a274a434a0285f8442efe851ef8c1377df8f9f72920d290c545b42eb56566c3ee0d53a124362
|
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
|
+
* https://github.com/sidekiq/sidekiq[Sidekiq]
|
138
|
+
** 7.2.x
|
139
|
+
** 7.3.x
|
140
|
+
* https://redis.io[Redis]
|
141
|
+
** 6.2.x
|
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
|
@@ -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.1.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: 2024-11-22 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.1.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.1.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
|