sidekiq-web_custom 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.circleci/config.yml +109 -0
- data/.gitignore +18 -0
- data/.rspec +3 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Dockerfile +18 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +182 -0
- data/LICENSE.txt +21 -0
- data/Makefile +40 -0
- data/README.md +92 -0
- data/Rakefile +8 -0
- data/bin/all_workers +69 -0
- data/bin/bundle +114 -0
- data/bin/publish +40 -0
- data/bin/publish_git +38 -0
- data/bin/publish_ruby_gems +22 -0
- data/bin/rails +18 -0
- data/bin/sidekiq +29 -0
- data/bin/sidekiqmon +29 -0
- data/docker-compose.yml +43 -0
- data/dummy_rails/.rspec +4 -0
- data/dummy_rails/app/assets/config/manifest.js +0 -0
- data/dummy_rails/app/controllers/application_controller.rb +2 -0
- data/dummy_rails/app/helpers/application_helper.rb +2 -0
- data/dummy_rails/app/views/layouts/application.html.erb +15 -0
- data/dummy_rails/app/views/layouts/mailer.html.erb +13 -0
- data/dummy_rails/app/workers/exclude_hard_worker.rb +15 -0
- data/dummy_rails/app/workers/exclude_lazy_worker.rb +11 -0
- data/dummy_rails/app/workers/exclude_random_raise_worker.rb +11 -0
- data/dummy_rails/app/workers/hard_worker.rb +15 -0
- data/dummy_rails/app/workers/lazy_worker.rb +10 -0
- data/dummy_rails/app/workers/random_raise_worker.rb +12 -0
- data/dummy_rails/app/workers/taco_worker.rb +12 -0
- data/dummy_rails/app/workers/tostada_worker.rb +11 -0
- data/dummy_rails/bin/rspec +5 -0
- data/dummy_rails/config.ru +5 -0
- data/dummy_rails/config/application.rb +20 -0
- data/dummy_rails/config/boot.rb +5 -0
- data/dummy_rails/config/environment.rb +5 -0
- data/dummy_rails/config/environments/development.rb +52 -0
- data/dummy_rails/config/environments/production.rb +88 -0
- data/dummy_rails/config/environments/test.rb +40 -0
- data/dummy_rails/config/initializers/assets.rb +14 -0
- data/dummy_rails/config/initializers/cookies_serializer.rb +5 -0
- data/dummy_rails/config/initializers/filter_parameter_logging.rb +4 -0
- data/dummy_rails/config/initializers/sidekiq-web_custom.rb +3 -0
- data/dummy_rails/config/initializers/wrap_parameters.rb +14 -0
- data/dummy_rails/config/locales/en.yml +33 -0
- data/dummy_rails/config/puma.rb +37 -0
- data/dummy_rails/config/routes.rb +5 -0
- data/dummy_rails/config/secrets.yml +5 -0
- data/dummy_rails/config/spring.rb +5 -0
- data/dummy_rails/config/storage.yml +34 -0
- data/dummy_rails/package.json +5 -0
- data/dummy_rails/spec/spec_helper.rb +50 -0
- data/lib/load_random_workers.rb +25 -0
- data/lib/sidekiq/views/actions/queues/delete.erb +12 -0
- data/lib/sidekiq/views/actions/queues/drain_queue.erb +4 -0
- data/lib/sidekiq/views/actions/queues/pause.erb +13 -0
- data/lib/sidekiq/views/actions/retries/delete.erb +5 -0
- data/lib/sidekiq/views/actions/retries/execute.erb +7 -0
- data/lib/sidekiq/views/actions/scheduled/delete.erb +5 -0
- data/lib/sidekiq/views/actions/scheduled/execute.erb +7 -0
- data/lib/sidekiq/views/queues.erb +64 -0
- data/lib/sidekiq/views/retries.erb +123 -0
- data/lib/sidekiq/views/scheduled.erb +97 -0
- data/lib/sidekiq/web_custom.rb +95 -0
- data/lib/sidekiq/web_custom/configuration.rb +112 -0
- data/lib/sidekiq/web_custom/job.rb +11 -0
- data/lib/sidekiq/web_custom/processor.rb +82 -0
- data/lib/sidekiq/web_custom/queue.rb +12 -0
- data/lib/sidekiq/web_custom/timeout.rb +64 -0
- data/lib/sidekiq/web_custom/version.rb +14 -0
- data/lib/sidekiq/web_custom/web_action.rb +38 -0
- data/lib/sidekiq/web_custom/web_app.rb +46 -0
- data/sidekiq-web_custom.gemspec +37 -0
- metadata +151 -0
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sidekiq
|
4
|
+
module WebCustom
|
5
|
+
MAJOR = 0 # With backwards incompatability. Requires annoucment and update documentation
|
6
|
+
MINOR = 2 # With feature launch. Documentation of upgrade is useful via a changelog
|
7
|
+
PATCH = 0 # With minor upgrades or patcing a small bug. No changelog necessary
|
8
|
+
VERSION = [MAJOR,MINOR,PATCH].join('.')
|
9
|
+
|
10
|
+
def self.get_version
|
11
|
+
puts VERSION
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sidekiq
|
4
|
+
module WebCustom
|
5
|
+
module WebAction
|
6
|
+
OVERWRITE_VALUE = '__sidekiq_web_custom_replacement__'
|
7
|
+
|
8
|
+
def self.local_erbs
|
9
|
+
@local_erbs ||= "#{File.expand_path("#{File.dirname(__FILE__)}/..")}/views"
|
10
|
+
end
|
11
|
+
|
12
|
+
def erb(content, options = {})
|
13
|
+
if content.is_a?(Symbol) && !Sidekiq::WebCustom.local_erb_mapping[content].nil?
|
14
|
+
unless respond_to?(:"_erb_#{content}")
|
15
|
+
file_name = Sidekiq::WebCustom.local_erb_mapping[content]
|
16
|
+
src = ERB.new(src_file_replacement(content)).src
|
17
|
+
WebAction.class_eval("def _erb_#{content}\n#{src}\n end", file_name)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
super(content, options)
|
21
|
+
end
|
22
|
+
|
23
|
+
def src_file_replacement(content)
|
24
|
+
file_name = Sidekiq::WebCustom.local_erb_mapping[content]
|
25
|
+
contents = File.read(file_name)
|
26
|
+
begin
|
27
|
+
available_actions = Sidekiq::WebCustom.config.public_send("actions_for_#{content}")
|
28
|
+
rescue NoMethodError
|
29
|
+
available_actions = []
|
30
|
+
end
|
31
|
+
actions = available_actions.map do |action, action_path|
|
32
|
+
File.read(action_path)
|
33
|
+
end.join(" ")
|
34
|
+
contents.gsub(OVERWRITE_VALUE, actions)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sidekiq
|
4
|
+
module WebCustom
|
5
|
+
class WebApp
|
6
|
+
MAPPED_TYPE = {
|
7
|
+
retries: RetrySet,
|
8
|
+
scheduled: ScheduledSet,
|
9
|
+
}
|
10
|
+
def self.registered(app)
|
11
|
+
app.post '/queues/drain/:name' do
|
12
|
+
timeout_params = {
|
13
|
+
warn: Sidekiq::WebCustom.config.warn_execution_time,
|
14
|
+
timeout: Sidekiq::WebCustom.config.max_execution_time,
|
15
|
+
proc: ->(thread, seconds) { thread[Sidekiq::WebCustom::BREAK_BIT] = 1; Sidekiq.logger.warn "set bit #{thread[Sidekiq::WebCustom::BREAK_BIT]}" }
|
16
|
+
}
|
17
|
+
Thread.current[Sidekiq::WebCustom::BREAK_BIT] = nil
|
18
|
+
Sidekiq::WebCustom::Timeout.timeout(timeout_params) do
|
19
|
+
Sidekiq::Queue.new(params[:name]).drain(max: Sidekiq::WebCustom.config.drain_rate)
|
20
|
+
end
|
21
|
+
redirect_with_query("#{root_path}queues")
|
22
|
+
end
|
23
|
+
|
24
|
+
app.post '/job/delete' do
|
25
|
+
parsed = parse_params(params['entry.score'])
|
26
|
+
|
27
|
+
klass = MAPPED_TYPE[params['entry.type'].to_sym]
|
28
|
+
job = klass.new.fetch(*parsed)&.first
|
29
|
+
|
30
|
+
job&.delete
|
31
|
+
redirect_with_query("#{root_path}scheduled")
|
32
|
+
end
|
33
|
+
|
34
|
+
app.post '/job/execute' do
|
35
|
+
parsed = parse_params(params['entry.score'])
|
36
|
+
|
37
|
+
klass = MAPPED_TYPE[params['entry.type'].to_sym]
|
38
|
+
job = klass.new.fetch(*parsed)&.first
|
39
|
+
|
40
|
+
status = job&.execute
|
41
|
+
redirect_with_query("#{root_path}#{params['entry.type']}")
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/sidekiq/web_custom/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "sidekiq-web_custom"
|
7
|
+
spec.version = Sidekiq::WebCustom::VERSION
|
8
|
+
spec.authors = ["Matt Taylor"]
|
9
|
+
spec.email = ["mattius.taylor@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = "This gem adds on custom capabilities to the Sidekiq Web UI"
|
12
|
+
spec.description = "Write a longer description or delete this line."
|
13
|
+
spec.homepage = "https://github.com/matt-taylor/sidekiq-web_custom"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
|
16
|
+
|
17
|
+
# spec.metadata["allowed_push_host"] = "Set to 'http://mygemserver.com'"
|
18
|
+
|
19
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
20
|
+
spec.metadata["source_code_uri"] = "https://github.com/matt-taylor/sidekiq-web_custom"
|
21
|
+
spec.metadata["changelog_uri"] = "https://github.com/matt-taylor/sidekiq-web_custom/blob/main/CHANGELOG.md"
|
22
|
+
|
23
|
+
# Specify which files should be added to the gem when it is released.
|
24
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
25
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
26
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
27
|
+
end
|
28
|
+
spec.bindir = "exe"
|
29
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
30
|
+
spec.require_paths = ["lib"]
|
31
|
+
|
32
|
+
spec.add_dependency 'sidekiq', '>= 6.0'
|
33
|
+
spec.add_dependency 'timeoutable'
|
34
|
+
|
35
|
+
# For more information and examples about making a new gem, checkout our
|
36
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
37
|
+
end
|
metadata
ADDED
@@ -0,0 +1,151 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sidekiq-web_custom
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Matt Taylor
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-07-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sidekiq
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '6.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '6.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: timeoutable
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Write a longer description or delete this line.
|
42
|
+
email:
|
43
|
+
- mattius.taylor@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".circleci/config.yml"
|
49
|
+
- ".gitignore"
|
50
|
+
- ".rspec"
|
51
|
+
- CHANGELOG.md
|
52
|
+
- CODE_OF_CONDUCT.md
|
53
|
+
- Dockerfile
|
54
|
+
- Gemfile
|
55
|
+
- Gemfile.lock
|
56
|
+
- LICENSE.txt
|
57
|
+
- Makefile
|
58
|
+
- README.md
|
59
|
+
- Rakefile
|
60
|
+
- bin/all_workers
|
61
|
+
- bin/bundle
|
62
|
+
- bin/publish
|
63
|
+
- bin/publish_git
|
64
|
+
- bin/publish_ruby_gems
|
65
|
+
- bin/rails
|
66
|
+
- bin/sidekiq
|
67
|
+
- bin/sidekiqmon
|
68
|
+
- docker-compose.yml
|
69
|
+
- dummy_rails/.rspec
|
70
|
+
- dummy_rails/app/assets/config/manifest.js
|
71
|
+
- dummy_rails/app/controllers/application_controller.rb
|
72
|
+
- dummy_rails/app/helpers/application_helper.rb
|
73
|
+
- dummy_rails/app/views/layouts/application.html.erb
|
74
|
+
- dummy_rails/app/views/layouts/mailer.html.erb
|
75
|
+
- dummy_rails/app/workers/exclude_hard_worker.rb
|
76
|
+
- dummy_rails/app/workers/exclude_lazy_worker.rb
|
77
|
+
- dummy_rails/app/workers/exclude_random_raise_worker.rb
|
78
|
+
- dummy_rails/app/workers/hard_worker.rb
|
79
|
+
- dummy_rails/app/workers/lazy_worker.rb
|
80
|
+
- dummy_rails/app/workers/random_raise_worker.rb
|
81
|
+
- dummy_rails/app/workers/taco_worker.rb
|
82
|
+
- dummy_rails/app/workers/tostada_worker.rb
|
83
|
+
- dummy_rails/bin/rspec
|
84
|
+
- dummy_rails/config.ru
|
85
|
+
- dummy_rails/config/application.rb
|
86
|
+
- dummy_rails/config/boot.rb
|
87
|
+
- dummy_rails/config/environment.rb
|
88
|
+
- dummy_rails/config/environments/development.rb
|
89
|
+
- dummy_rails/config/environments/production.rb
|
90
|
+
- dummy_rails/config/environments/test.rb
|
91
|
+
- dummy_rails/config/initializers/assets.rb
|
92
|
+
- dummy_rails/config/initializers/cookies_serializer.rb
|
93
|
+
- dummy_rails/config/initializers/filter_parameter_logging.rb
|
94
|
+
- dummy_rails/config/initializers/sidekiq-web_custom.rb
|
95
|
+
- dummy_rails/config/initializers/wrap_parameters.rb
|
96
|
+
- dummy_rails/config/locales/en.yml
|
97
|
+
- dummy_rails/config/puma.rb
|
98
|
+
- dummy_rails/config/routes.rb
|
99
|
+
- dummy_rails/config/secrets.yml
|
100
|
+
- dummy_rails/config/spring.rb
|
101
|
+
- dummy_rails/config/storage.yml
|
102
|
+
- dummy_rails/package.json
|
103
|
+
- dummy_rails/spec/spec_helper.rb
|
104
|
+
- lib/load_random_workers.rb
|
105
|
+
- lib/sidekiq/views/actions/queues/delete.erb
|
106
|
+
- lib/sidekiq/views/actions/queues/drain_queue.erb
|
107
|
+
- lib/sidekiq/views/actions/queues/pause.erb
|
108
|
+
- lib/sidekiq/views/actions/retries/delete.erb
|
109
|
+
- lib/sidekiq/views/actions/retries/execute.erb
|
110
|
+
- lib/sidekiq/views/actions/scheduled/delete.erb
|
111
|
+
- lib/sidekiq/views/actions/scheduled/execute.erb
|
112
|
+
- lib/sidekiq/views/queues.erb
|
113
|
+
- lib/sidekiq/views/retries.erb
|
114
|
+
- lib/sidekiq/views/scheduled.erb
|
115
|
+
- lib/sidekiq/web_custom.rb
|
116
|
+
- lib/sidekiq/web_custom/configuration.rb
|
117
|
+
- lib/sidekiq/web_custom/job.rb
|
118
|
+
- lib/sidekiq/web_custom/processor.rb
|
119
|
+
- lib/sidekiq/web_custom/queue.rb
|
120
|
+
- lib/sidekiq/web_custom/timeout.rb
|
121
|
+
- lib/sidekiq/web_custom/version.rb
|
122
|
+
- lib/sidekiq/web_custom/web_action.rb
|
123
|
+
- lib/sidekiq/web_custom/web_app.rb
|
124
|
+
- sidekiq-web_custom.gemspec
|
125
|
+
homepage: https://github.com/matt-taylor/sidekiq-web_custom
|
126
|
+
licenses:
|
127
|
+
- MIT
|
128
|
+
metadata:
|
129
|
+
homepage_uri: https://github.com/matt-taylor/sidekiq-web_custom
|
130
|
+
source_code_uri: https://github.com/matt-taylor/sidekiq-web_custom
|
131
|
+
changelog_uri: https://github.com/matt-taylor/sidekiq-web_custom/blob/main/CHANGELOG.md
|
132
|
+
post_install_message:
|
133
|
+
rdoc_options: []
|
134
|
+
require_paths:
|
135
|
+
- lib
|
136
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
137
|
+
requirements:
|
138
|
+
- - ">="
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: 2.4.0
|
141
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
requirements: []
|
147
|
+
rubygems_version: 3.2.15
|
148
|
+
signing_key:
|
149
|
+
specification_version: 4
|
150
|
+
summary: This gem adds on custom capabilities to the Sidekiq Web UI
|
151
|
+
test_files: []
|