sidekiq-belt 2.0.1 → 2.0.4
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/CHANGELOG.md +7 -0
- data/README.md +10 -0
- data/lib/sidekiq/belt/community/run_job.rb +26 -3
- data/lib/sidekiq/belt/community/views/run_jobs.erb +28 -3
- data/lib/sidekiq/belt/ent/periodic_pause.rb +4 -57
- data/lib/sidekiq/belt/ent/periodic_run.rb +2 -13
- data/lib/sidekiq/belt/pro/failed_batch_remove.rb +2 -2
- data/lib/sidekiq/belt/version.rb +1 -1
- data/lib/sidekiq/web_action_helper.rb +2 -10
- data/lib/sidekiq/web_router_helper.rb +1 -5
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7dec0e6d4e3842e7f5ce45c84049764adbfe7f0051c5fa477624359b06f67322
|
4
|
+
data.tar.gz: 588a98f3e5292907b5cabb98ef2f42804917e71662e79bb17cc10bb7b5408445
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 973105fbafe85ab4d03c27f46e54dbbbfad9c0d51a7e21662c10283dc2252a7de1ff42a0e38fe265ec244ed87a6fcfa3eea0362b4751a550aaa1c1d735c40fbb
|
7
|
+
data.tar.gz: ca82931ae4c4300d72ce65c9976ff115bfcc242ad8a6f587d774786256a8a96b89630a1272bbb835237e83195695b17ffca35164e8dd64d77c47e5baa865e3ac
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -113,6 +113,16 @@ Sidekiq::Belt.configure do |config|
|
|
113
113
|
|
114
114
|
config.run_jobs << { class: "CWorker", args: ["a"], group: "Etc" }
|
115
115
|
config.run_jobs << { class: "DWorker", args: ["a"], group: "Etc" }
|
116
|
+
|
117
|
+
config.run_jobs << { class: "EWorker", args: [
|
118
|
+
{ dynamic: 'text', title: 'Observation' },
|
119
|
+
{ dynamic: 'integer', title: 'Number of test' },
|
120
|
+
'fixed value A',
|
121
|
+
{ dynamic: 'boolean', title: 'Boolean data' },
|
122
|
+
{ dynamic: 'enum', title: 'Enum data', options: ['option1', 'option2', 'option3'], default: 'option2' },
|
123
|
+
'fixed value B'
|
124
|
+
], group: "Etc" }
|
125
|
+
config.run_jobs << { class: "FWorker", args: ["a"], group: "Etc" }
|
116
126
|
end
|
117
127
|
```
|
118
128
|
|
@@ -20,11 +20,32 @@ module Sidekiq
|
|
20
20
|
jobs
|
21
21
|
end
|
22
22
|
|
23
|
-
def self.
|
23
|
+
def self.dynamic_type?(arg, type)
|
24
|
+
return false unless arg.is_a?(Hash)
|
25
|
+
|
26
|
+
arg[:dynamic].to_s == type
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.run_job(job_id, extra_args = {})
|
24
30
|
job = Sidekiq::Belt.config.run_jobs[job_id.to_i]
|
25
31
|
job.transform_keys(&:to_sym)
|
26
32
|
|
27
|
-
|
33
|
+
args = job.fetch(:args, [])
|
34
|
+
|
35
|
+
new_args = []
|
36
|
+
args.each_with_index do |arg, i|
|
37
|
+
if dynamic_type?(arg, "text") || dynamic_type?(arg, "enum")
|
38
|
+
new_args[i] = extra_args.shift
|
39
|
+
elsif dynamic_type?(arg, "integer")
|
40
|
+
new_args[i] = extra_args.shift.to_i
|
41
|
+
elsif dynamic_type?(arg, "boolean")
|
42
|
+
new_args[i] = extra_args.shift == "true"
|
43
|
+
else
|
44
|
+
new_args << arg
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
Module.const_get(job[:class]).perform_async(*new_args)
|
28
49
|
end
|
29
50
|
|
30
51
|
module SidekiqRunJob
|
@@ -36,7 +57,9 @@ module Sidekiq
|
|
36
57
|
end
|
37
58
|
|
38
59
|
app.post("/run_jobs/:rjid/run") do
|
39
|
-
|
60
|
+
args = url_params("args")
|
61
|
+
|
62
|
+
Sidekiq::Belt::Community::RunJob.run_job(route_params(:rjid).to_i, args)
|
40
63
|
|
41
64
|
return redirect "#{root_path}run_jobs"
|
42
65
|
end
|
@@ -14,10 +14,35 @@
|
|
14
14
|
<% jobs.each do |job| %>
|
15
15
|
<tr>
|
16
16
|
<td><%= job[:class] %></td>
|
17
|
-
<td
|
18
|
-
|
19
|
-
|
17
|
+
<td colspan="2">
|
18
|
+
<form action="<%= root_path %>run_jobs/<%= job[:id] %>/run" class="force-run-form" method="post">
|
19
|
+
<%= '[' %>
|
20
|
+
<% (job[:args] || []).each_with_index do |arg, i| %>
|
21
|
+
<% if Sidekiq::Belt::Community::RunJob.dynamic_type?(arg, 'text') %>
|
22
|
+
<input type="text" class="form-control" name="args[]" title="<%= arg[:title] %>" required='true' placeholder="<%= arg[:title] %>" value="<%= arg[:default] %>" />
|
23
|
+
<% elsif Sidekiq::Belt::Community::RunJob.dynamic_type?(arg, 'integer') %>
|
24
|
+
<input type="number" class="form-control" name="args[]" title="<%= arg[:title] %>" required='true' placeholder="<%= arg[:title] %>" value="<%= arg[:default] %>" />
|
25
|
+
<% elsif Sidekiq::Belt::Community::RunJob.dynamic_type?(arg, 'boolean') %>
|
26
|
+
<select class="form-control" name="args[]" required='true' title="<%= arg[:title] %>" placeholder="<%= arg[:title] %>">
|
27
|
+
<option value="true" <%= arg[:default] == 'true' ? 'selected' : '' %>>true</option>
|
28
|
+
<option value="false" <%= arg[:default] == 'false' ? 'selected' : '' %>>false</option>
|
29
|
+
</select>
|
30
|
+
<% elsif Sidekiq::Belt::Community::RunJob.dynamic_type?(arg, 'enum') %>
|
31
|
+
<select class="form-control" name="args[]" required='true' title="<%= arg[:title] %>" placeholder="<%= arg[:title] %>">
|
32
|
+
<% arg[:options].each do |option| %>
|
33
|
+
<option value="<%= option %>" <%= arg[:default].to_s == option.to_s ? 'selected' : '' %>><%= option %></option>
|
34
|
+
<% end %>
|
35
|
+
</select>
|
36
|
+
<% else %>
|
37
|
+
<input type="hidden" name="args[]" value="<%= arg %>" />
|
38
|
+
<%= arg.inspect %>
|
39
|
+
<% end %>
|
40
|
+
<%= ',' if i < (job[:args] || []).size - 1 %>
|
41
|
+
<% end %>
|
42
|
+
<%= ']' %>
|
43
|
+
|
20
44
|
<%= csrf_tag %>
|
45
|
+
|
21
46
|
<input class="btn btn-danger" type="submit" name="run" value="<%= t('Run') %>"
|
22
47
|
data-confirm="Run the job <%= job[:klass] %>? <%= t('AreYouSure') %>" />
|
23
48
|
</form>
|
@@ -6,33 +6,13 @@ module Sidekiq
|
|
6
6
|
module Belt
|
7
7
|
module Ent
|
8
8
|
module PeriodicPause
|
9
|
-
def paused?
|
10
|
-
Sidekiq.redis { |r| r.hget("PeriodicPaused", @lid.to_s) }.to_s == "p"
|
11
|
-
end
|
12
|
-
|
13
|
-
def pause!
|
14
|
-
Sidekiq.redis { |r| r.hset("PeriodicPaused", @lid.to_s, "p") }
|
15
|
-
end
|
16
|
-
|
17
|
-
def unpause!
|
18
|
-
Sidekiq.redis { |r| r.hdel("PeriodicPaused", @lid.to_s) }
|
19
|
-
end
|
20
|
-
|
21
9
|
module SidekiqLoopsPeriodicPause
|
22
10
|
PAUSE_BUTTON = <<~ERB
|
23
|
-
|
24
|
-
<%= csrf_tag %>
|
25
|
-
<input class="btn btn-danger btn-pause" type="submit" name="pause" value="<%= t('Pause') %>"
|
26
|
-
data-confirm="Pause the job <%= loup.klass %>? <%= t('AreYouSure') %>" />
|
27
|
-
</form>
|
11
|
+
name="pause" data-confirm="Pause the job <%= loup.klass %>? <%= t('AreYouSure') %>"
|
28
12
|
ERB
|
29
13
|
|
30
14
|
UNPAUSE_BUTTON = <<~ERB
|
31
|
-
|
32
|
-
<%= csrf_tag %>
|
33
|
-
<input class="btn btn-danger btn-unpause" type="submit" name="pause" value="<%= t('Unpause') %>"
|
34
|
-
data-confirm="Unpause the job <%= loup.klass %>? <%= t('AreYouSure') %>" />
|
35
|
-
</form>
|
15
|
+
name="unpause" data-confirm="Unpause the job <%= loup.klass %>? <%= t('AreYouSure') %>"
|
36
16
|
ERB
|
37
17
|
|
38
18
|
def self.registered(app)
|
@@ -49,52 +29,19 @@ module Sidekiq
|
|
49
29
|
}
|
50
30
|
</style>")
|
51
31
|
|
52
|
-
|
53
|
-
content.gsub!("
|
54
|
-
|
55
|
-
# Add the run button
|
56
|
-
content.gsub!(
|
57
|
-
"</td>\n </tr>\n <% end %>",
|
58
|
-
"</td>\n<td>" \
|
59
|
-
"<% if (loup.paused?) %>#{UNPAUSE_BUTTON}<% else %>#{PAUSE_BUTTON}<% end %>" \
|
60
|
-
"</td>\n </tr>\n <% end %>"
|
61
|
-
)
|
62
|
-
end
|
63
|
-
|
64
|
-
app.post("/loops/:lid/pause") do
|
65
|
-
Sidekiq::Periodic::Loop.new(route_params(:lid)).pause!
|
66
|
-
|
67
|
-
return redirect "#{root_path}loops"
|
68
|
-
end
|
69
|
-
|
70
|
-
app.post("/loops/:lid/unpause") do
|
71
|
-
Sidekiq::Periodic::Loop.new(route_params(:lid)).unpause!
|
72
|
-
|
73
|
-
return redirect "#{root_path}loops"
|
32
|
+
content.gsub!("name=\"pause\"", PAUSE_BUTTON)
|
33
|
+
content.gsub!("name=\"unpause\"", UNPAUSE_BUTTON)
|
74
34
|
end
|
75
35
|
end
|
76
36
|
end
|
77
37
|
|
78
|
-
module PauseServer
|
79
|
-
def enqueue_job(cycle, ts)
|
80
|
-
cycle.paused? ? logger.info("Job #{cycle.klass} is paused by Periodic Pause") : super
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
38
|
def self.use!
|
85
39
|
require("sidekiq-ent/web")
|
86
|
-
require("sidekiq-ent/periodic")
|
87
|
-
require("sidekiq-ent/periodic/manager")
|
88
|
-
require("sidekiq-ent/periodic/static_loop")
|
89
40
|
|
90
41
|
Sidekiq::Web.configure do |cfg|
|
91
42
|
cfg.register(Sidekiq::Belt::Ent::PeriodicPause::SidekiqLoopsPeriodicPause, name: "periodic_pause",
|
92
43
|
tab: nil, index: nil)
|
93
44
|
end
|
94
|
-
|
95
|
-
Sidekiq::Periodic::Loop.prepend(Sidekiq::Belt::Ent::PeriodicPause)
|
96
|
-
Sidekiq::Periodic::StaticLoop.prepend(Sidekiq::Belt::Ent::PeriodicPause)
|
97
|
-
Sidekiq::Periodic::Manager.prepend(Sidekiq::Belt::Ent::PeriodicPause::PauseServer)
|
98
45
|
end
|
99
46
|
end
|
100
47
|
end
|
@@ -18,11 +18,7 @@ module Sidekiq
|
|
18
18
|
|
19
19
|
module SidekiqLoopsPeriodicRun
|
20
20
|
FORCE_RUN_BUTTON = <<~ERB
|
21
|
-
|
22
|
-
<%= csrf_tag %>
|
23
|
-
<input class="btn btn-danger" type="submit" name="run" value="<%= t('Run now') %>"
|
24
|
-
data-confirm="Run the job <%= loup.klass %>? <%= t('AreYouSure') %>" />
|
25
|
-
</form>
|
21
|
+
name="enqueue" data-confirm="Enqueue the job <%= loup.klass %>? <%= t('AreYouSure') %>"
|
26
22
|
ERB
|
27
23
|
|
28
24
|
FORCE_RUN_SINGLE_PAGE = <<~ERB
|
@@ -41,14 +37,7 @@ module Sidekiq
|
|
41
37
|
|
42
38
|
def self.registered(app)
|
43
39
|
app.replace_content("/loops") do |content|
|
44
|
-
|
45
|
-
content.gsub!("</th>\n </tr>", "</th><th><%= t('Force Run') %></th></th>\n </tr>")
|
46
|
-
|
47
|
-
# Add the run button
|
48
|
-
content.gsub!(
|
49
|
-
"</td>\n </tr>\n <% end %>",
|
50
|
-
"</td>\n<td>#{FORCE_RUN_BUTTON}</td>\n </tr>\n <% end %>"
|
51
|
-
)
|
40
|
+
content.gsub!("name=\"enqueue\"", FORCE_RUN_BUTTON)
|
52
41
|
end
|
53
42
|
|
54
43
|
app.replace_content("/loops/:lid") do |content|
|
@@ -17,10 +17,10 @@ module Sidekiq
|
|
17
17
|
|
18
18
|
def self.registered(app)
|
19
19
|
app.replace_content("/batches") do |content|
|
20
|
-
content.gsub!("</th>\n
|
20
|
+
content.gsub!("</th>\n <%", "</th><th><%= t('Delete') %></th>\n <%")
|
21
21
|
|
22
22
|
content.gsub!(
|
23
|
-
"</td>\n
|
23
|
+
"</td>\n </tr>\n <% end %>",
|
24
24
|
"</td>\n<td>#{REMOVE_BUTTON}</td>\n </tr>\n <% end %>"
|
25
25
|
)
|
26
26
|
end
|
data/lib/sidekiq/belt/version.rb
CHANGED
@@ -10,11 +10,7 @@ module Sidekiq
|
|
10
10
|
replace_views = Sidekiq::Config::DEFAULTS[:replace_views] || {}
|
11
11
|
|
12
12
|
replace_views.each do |key, content_blocks|
|
13
|
-
router =
|
14
|
-
Sidekiq::Web::Route.new(self.class.sidekiq_request_method, key, true)
|
15
|
-
else
|
16
|
-
WebRoute.new(self.class.sidekiq_request_method, key, true)
|
17
|
-
end
|
13
|
+
router = Sidekiq::Web::Route.new(self.class.sidekiq_request_method, key, true)
|
18
14
|
|
19
15
|
next if router.match(self.class.sidekiq_request_method, self.class.sidekiq_path_info).nil?
|
20
16
|
|
@@ -56,9 +52,5 @@ module Sidekiq
|
|
56
52
|
end
|
57
53
|
end
|
58
54
|
|
59
|
-
|
60
|
-
Sidekiq::Web::Action.prepend(Sidekiq::WebActionHelper)
|
61
|
-
else
|
62
|
-
Sidekiq::WebAction.prepend(Sidekiq::WebActionHelper)
|
63
|
-
end
|
55
|
+
Sidekiq::Web::Action.prepend(Sidekiq::WebActionHelper)
|
64
56
|
end
|
@@ -13,9 +13,5 @@ module Sidekiq
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
|
17
|
-
Sidekiq::Web::Router.prepend(Sidekiq::WebRouterHelper)
|
18
|
-
else
|
19
|
-
Sidekiq::WebRouter.prepend(Sidekiq::WebRouterHelper)
|
20
|
-
end
|
16
|
+
Sidekiq::Web::Router.prepend(Sidekiq::WebRouterHelper)
|
21
17
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidekiq-belt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Danilo Jeremias da Silva
|
8
8
|
bindir: exe
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-
|
10
|
+
date: 2025-06-02 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: sidekiq
|
@@ -15,14 +15,14 @@ dependencies:
|
|
15
15
|
requirements:
|
16
16
|
- - ">="
|
17
17
|
- !ruby/object:Gem::Version
|
18
|
-
version:
|
18
|
+
version: 8.0.1
|
19
19
|
type: :runtime
|
20
20
|
prerelease: false
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
22
22
|
requirements:
|
23
23
|
- - ">="
|
24
24
|
- !ruby/object:Gem::Version
|
25
|
-
version:
|
25
|
+
version: 8.0.1
|
26
26
|
description: This Ruby gem enhances the capabilities of Sidekiq, Sidekiq Pro, and
|
27
27
|
Sidekiq Enterprise by adding essential utilities.
|
28
28
|
email:
|