sidekiq-belt 2.0.0 → 2.0.2
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 +8 -1
- 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/version.rb +1 -1
- data/lib/sidekiq/web_action_helper.rb +10 -7
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f2ad0b7e0a234a3f527f27a450a25c6cdf14c34387bfb38593e3637eed9eac1
|
4
|
+
data.tar.gz: a3eff6ee04902f1d4ae8e493f5d96e99038ca57511fc1720cc7343a0acd04525
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21012fc5d259e318c26a62765a74ab985f5ad1bff20757616672d2d37ce2f33e85b6c52318eb8b67c6fbeb51c62714f72a4e367330a3f84cc95a199c5a05c823
|
7
|
+
data.tar.gz: f04b7d0a4d5fa342d29d2220c32f05545c9ad824c5c869fcbe8e5ec80c401d0d1f7a1665e4b79cb728609ea161d3e2959decb19c43738384a526b562b17fba02
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
## [Unreleased]
|
2
|
-
|
2
|
+
|
3
|
+
## [2.0.2] - 2025-03-23
|
4
|
+
- Dynamic args on Jobs Run
|
5
|
+
|
6
|
+
## [2.0.1] - 2025-03-11
|
7
|
+
- Fix Support to Sidekiq-ent and Sidekiq-pro v8
|
8
|
+
|
9
|
+
## [2.0.0] - 2025-02-09
|
3
10
|
- Support for Sidekiq v8
|
4
11
|
|
5
12
|
## [1.0.0] - 2024-11-19
|
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>
|
data/lib/sidekiq/belt/version.rb
CHANGED
@@ -10,11 +10,13 @@ module Sidekiq
|
|
10
10
|
replace_views = Sidekiq::Config::DEFAULTS[:replace_views] || {}
|
11
11
|
|
12
12
|
replace_views.each do |key, content_blocks|
|
13
|
-
if Sidekiq::VERSION.to_i >= 8
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
router = if Sidekiq::VERSION.to_i >= 8
|
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
|
18
|
+
|
19
|
+
next if router.match(self.class.sidekiq_request_method, self.class.sidekiq_path_info).nil?
|
18
20
|
|
19
21
|
content_blocks.each do |content_block|
|
20
22
|
content_block.call(content)
|
@@ -25,12 +27,13 @@ module Sidekiq
|
|
25
27
|
end
|
26
28
|
|
27
29
|
class << self
|
28
|
-
attr_accessor :
|
30
|
+
attr_accessor :sidekiq_request_method, :sidekiq_path_info
|
29
31
|
end
|
30
32
|
end
|
31
33
|
|
32
34
|
def erb(content, options = {})
|
33
|
-
ERB.
|
35
|
+
ERB.sidekiq_request_method = env["REQUEST_METHOD"].to_s.downcase
|
36
|
+
ERB.sidekiq_path_info = env["PATH_INFO"].to_s
|
34
37
|
|
35
38
|
super
|
36
39
|
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.2
|
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-03-23 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: sidekiq
|
@@ -78,7 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
78
78
|
- !ruby/object:Gem::Version
|
79
79
|
version: '0'
|
80
80
|
requirements: []
|
81
|
-
rubygems_version: 3.6.
|
81
|
+
rubygems_version: 3.6.3
|
82
82
|
specification_version: 4
|
83
83
|
summary: This Ruby gem enhances the capabilities of Sidekiq, Sidekiq Pro, and Sidekiq
|
84
84
|
Enterprise by adding essential utilities.
|