sidekiq-web-workers 1.0.1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: af724a8900c3184aced22d239d874c61f510aa4ef71c1e674569d0d116378837
4
+ data.tar.gz: 344a73c807a2dedbcf5453ccb91a2a80f4fa52f6617fb4940ce5d385591dfbe6
5
+ SHA512:
6
+ metadata.gz: 5b50a8c80eb7569bb78be1af8fbb47b2bb82370262f91d1b1c1765f821bc186ffdd280462a6626fea718ce25a90962a564f6299619364dc382460455b843530b
7
+ data.tar.gz: 6cb25e5b818714d858e04c1783a99c4bf9a89356490fbd345f3993756724b08515df872f2841a6a750b372801ad9014a61dc26cff374f3071f45a4ad12933400
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /.idea/*
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.7.1
6
+ before_install: gem install bundler -v 2.1.4
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at josh.etsenake@clio.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [https://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: https://contributor-covenant.org
74
+ [version]: https://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in sidekiq_web_run_jobs.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
7
+ gem "rspec", "~> 3.0"
@@ -0,0 +1,169 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ sidekiq_web_run_jobs (1.0.1)
5
+ rails (>= 5.0)
6
+ sidekiq (>= 3)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ actioncable (6.0.3.2)
12
+ actionpack (= 6.0.3.2)
13
+ nio4r (~> 2.0)
14
+ websocket-driver (>= 0.6.1)
15
+ actionmailbox (6.0.3.2)
16
+ actionpack (= 6.0.3.2)
17
+ activejob (= 6.0.3.2)
18
+ activerecord (= 6.0.3.2)
19
+ activestorage (= 6.0.3.2)
20
+ activesupport (= 6.0.3.2)
21
+ mail (>= 2.7.1)
22
+ actionmailer (6.0.3.2)
23
+ actionpack (= 6.0.3.2)
24
+ actionview (= 6.0.3.2)
25
+ activejob (= 6.0.3.2)
26
+ mail (~> 2.5, >= 2.5.4)
27
+ rails-dom-testing (~> 2.0)
28
+ actionpack (6.0.3.2)
29
+ actionview (= 6.0.3.2)
30
+ activesupport (= 6.0.3.2)
31
+ rack (~> 2.0, >= 2.0.8)
32
+ rack-test (>= 0.6.3)
33
+ rails-dom-testing (~> 2.0)
34
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
35
+ actiontext (6.0.3.2)
36
+ actionpack (= 6.0.3.2)
37
+ activerecord (= 6.0.3.2)
38
+ activestorage (= 6.0.3.2)
39
+ activesupport (= 6.0.3.2)
40
+ nokogiri (>= 1.8.5)
41
+ actionview (6.0.3.2)
42
+ activesupport (= 6.0.3.2)
43
+ builder (~> 3.1)
44
+ erubi (~> 1.4)
45
+ rails-dom-testing (~> 2.0)
46
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
47
+ activejob (6.0.3.2)
48
+ activesupport (= 6.0.3.2)
49
+ globalid (>= 0.3.6)
50
+ activemodel (6.0.3.2)
51
+ activesupport (= 6.0.3.2)
52
+ activerecord (6.0.3.2)
53
+ activemodel (= 6.0.3.2)
54
+ activesupport (= 6.0.3.2)
55
+ activestorage (6.0.3.2)
56
+ actionpack (= 6.0.3.2)
57
+ activejob (= 6.0.3.2)
58
+ activerecord (= 6.0.3.2)
59
+ marcel (~> 0.3.1)
60
+ activesupport (6.0.3.2)
61
+ concurrent-ruby (~> 1.0, >= 1.0.2)
62
+ i18n (>= 0.7, < 2)
63
+ minitest (~> 5.1)
64
+ tzinfo (~> 1.1)
65
+ zeitwerk (~> 2.2, >= 2.2.2)
66
+ builder (3.2.4)
67
+ coderay (1.1.3)
68
+ concurrent-ruby (1.1.7)
69
+ connection_pool (2.2.3)
70
+ crass (1.0.6)
71
+ diff-lcs (1.4.4)
72
+ erubi (1.9.0)
73
+ globalid (0.4.2)
74
+ activesupport (>= 4.2.0)
75
+ i18n (1.8.5)
76
+ concurrent-ruby (~> 1.0)
77
+ loofah (2.6.0)
78
+ crass (~> 1.0.2)
79
+ nokogiri (>= 1.5.9)
80
+ mail (2.7.1)
81
+ mini_mime (>= 0.1.1)
82
+ marcel (0.3.3)
83
+ mimemagic (~> 0.3.2)
84
+ method_source (1.0.0)
85
+ mimemagic (0.3.5)
86
+ mini_mime (1.0.2)
87
+ mini_portile2 (2.4.0)
88
+ minitest (5.14.1)
89
+ nio4r (2.5.2)
90
+ nokogiri (1.10.10)
91
+ mini_portile2 (~> 2.4.0)
92
+ pry (0.13.1)
93
+ coderay (~> 1.1)
94
+ method_source (~> 1.0)
95
+ rack (2.2.3)
96
+ rack-test (1.1.0)
97
+ rack (>= 1.0, < 3)
98
+ rails (6.0.3.2)
99
+ actioncable (= 6.0.3.2)
100
+ actionmailbox (= 6.0.3.2)
101
+ actionmailer (= 6.0.3.2)
102
+ actionpack (= 6.0.3.2)
103
+ actiontext (= 6.0.3.2)
104
+ actionview (= 6.0.3.2)
105
+ activejob (= 6.0.3.2)
106
+ activemodel (= 6.0.3.2)
107
+ activerecord (= 6.0.3.2)
108
+ activestorage (= 6.0.3.2)
109
+ activesupport (= 6.0.3.2)
110
+ bundler (>= 1.3.0)
111
+ railties (= 6.0.3.2)
112
+ sprockets-rails (>= 2.0.0)
113
+ rails-dom-testing (2.0.3)
114
+ activesupport (>= 4.2.0)
115
+ nokogiri (>= 1.6)
116
+ rails-html-sanitizer (1.3.0)
117
+ loofah (~> 2.3)
118
+ railties (6.0.3.2)
119
+ actionpack (= 6.0.3.2)
120
+ activesupport (= 6.0.3.2)
121
+ method_source
122
+ rake (>= 0.8.7)
123
+ thor (>= 0.20.3, < 2.0)
124
+ rake (12.3.3)
125
+ redis (4.2.1)
126
+ rspec (3.9.0)
127
+ rspec-core (~> 3.9.0)
128
+ rspec-expectations (~> 3.9.0)
129
+ rspec-mocks (~> 3.9.0)
130
+ rspec-core (3.9.2)
131
+ rspec-support (~> 3.9.3)
132
+ rspec-expectations (3.9.2)
133
+ diff-lcs (>= 1.2.0, < 2.0)
134
+ rspec-support (~> 3.9.0)
135
+ rspec-mocks (3.9.1)
136
+ diff-lcs (>= 1.2.0, < 2.0)
137
+ rspec-support (~> 3.9.0)
138
+ rspec-support (3.9.3)
139
+ sidekiq (6.1.1)
140
+ connection_pool (>= 2.2.2)
141
+ rack (~> 2.0)
142
+ redis (>= 4.2.0)
143
+ sprockets (4.0.2)
144
+ concurrent-ruby (~> 1.0)
145
+ rack (> 1, < 3)
146
+ sprockets-rails (3.2.1)
147
+ actionpack (>= 4.0)
148
+ activesupport (>= 4.0)
149
+ sprockets (>= 3.0.0)
150
+ thor (1.0.1)
151
+ thread_safe (0.3.6)
152
+ tzinfo (1.2.7)
153
+ thread_safe (~> 0.1)
154
+ websocket-driver (0.7.3)
155
+ websocket-extensions (>= 0.1.0)
156
+ websocket-extensions (0.1.5)
157
+ zeitwerk (2.4.0)
158
+
159
+ PLATFORMS
160
+ ruby
161
+
162
+ DEPENDENCIES
163
+ pry (~> 0.1)
164
+ rake (~> 12.0)
165
+ rspec (~> 3.0)
166
+ sidekiq_web_run_jobs!
167
+
168
+ BUNDLED WITH
169
+ 2.1.4
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Josh Etsenake
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,46 @@
1
+ # SidekiqWebRunJobs
2
+
3
+ `sidekiq_web_run_jobs` is an extension to Sidekiq that allows you to run jobs from your sidekiq web ui
4
+
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'sidekiq_web_run_jobs'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle install
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install sidekiq_web_run_jobs
21
+
22
+ ## Usage
23
+
24
+ Once you've installed the gem to add workers that will show up in the web workers section, you'll need to make a file called `sidekiq_web_jobs.yml` in your application root config folders.
25
+ If your application is not rails standard or simply wish to change the default location the gem searches for the `sidekiq_web_jobs.yml` you can do so as follows in your `sidekiq.rb` initializer.
26
+
27
+ `Sidekiq::WebWorkers.config_root = <folder you want>`
28
+
29
+ ## Development
30
+
31
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
32
+
33
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
34
+
35
+ ## Contributing
36
+
37
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/sidekiq_web_run_jobs. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/etsenake/sidekiq_web_run_jobs/blob/master/CODE_OF_CONDUCT.md).
38
+
39
+
40
+ ## License
41
+
42
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
43
+
44
+ ## Code of Conduct
45
+
46
+ Everyone interacting in the SidekiqWebRunJobs project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/sidekiq_web_run_jobs/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "sidekiq_web_run_jobs"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "pry"
14
+ Pry.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,3 @@
1
+ require 'sidekiq_web_run_jobs/job_runner'
2
+
3
+ Sidekiq::WebWorkers = SidekiqWebRunJobs
@@ -0,0 +1,47 @@
1
+ require 'sidekiq'
2
+ require 'rails'
3
+ require 'sidekiq/job_runner'
4
+ require 'sidekiq_web_run_jobs/job_presenter'
5
+ require 'sidekiq_web_run_jobs/version'
6
+ require 'sidekiq_web_run_jobs/job_runner'
7
+ require 'sidekiq_web_run_jobs/web'
8
+ require 'sidekiq_web_run_jobs/extensions/web'
9
+
10
+ module SidekiqWebRunJobs
11
+ def self.jobs
12
+ @jobs ||= load_jobs.uniq
13
+ end
14
+
15
+ def self.config_root=(path = Rails.root)
16
+ @config_root = path if path.is_a? Pathname
17
+ @config_root = Pathname.new(path)
18
+ end
19
+
20
+ def self.load_jobs
21
+ if config_path.present?
22
+ YAML.load_file(config_path)
23
+ else
24
+ []
25
+ end
26
+ rescue Errno::ENOENT
27
+ Sidekiq.logger.warn("YAML configuration file couldn't be found")
28
+ []
29
+ rescue Psych::SyntaxError
30
+ Sidekiq.logger.warn("YAML configuration file contains invalid syntax")
31
+ []
32
+ end
33
+
34
+ def self.config_path
35
+ @config_root&.join("config", "sidekiq_web_jobs.yml")
36
+ end
37
+
38
+ def self.search_jobs(search_text)
39
+ job_names = SidekiqWebRunJobs.jobs
40
+ return job_names unless search_text.present?
41
+
42
+ job_names.map{ |job_name| JobPresenter.new(job_name) }
43
+ .delete_if(&:empty?)
44
+ .find_all { |job| job.include?(search_text) }
45
+ end
46
+ end
47
+
@@ -0,0 +1,6 @@
1
+ require 'sidekiq/web' unless defined?(Sidekiq::Web)
2
+ require 'sidekiq_web_run_jobs/web'
3
+
4
+ Sidekiq::Web.register(SidekiqWebRunJobs::Web)
5
+ Sidekiq::Web.tabs['Web Workers'] = 'run_jobs'
6
+ Sidekiq::Web.locales << File.expand_path(File.dirname(__FILE__) + '/../../../web/locales')
@@ -0,0 +1,41 @@
1
+ class JobPresenter
2
+ attr_reader :worker_name
3
+
4
+ def initialize(job_name)
5
+ @worker_name = job_name
6
+ end
7
+
8
+ def description
9
+ job_constantized.respond_to?(:description) ? job_constantized.description : ""
10
+ end
11
+
12
+ def method_arguments
13
+ return [] unless job_constantized
14
+ job_constantized.new.method(:perform).parameters
15
+ #[[:opt, :param_name], [:req, :param_name]] empty if no params
16
+ # for named parameters this can be [[:key, :param_name], [:keyreq, :param_name]]
17
+ # key means optional keyreq means required but sidekiq does not s
18
+ # sidekiq doesn't support named args tho https://github.com/mperham/sidekiq/issues/2372
19
+ end
20
+
21
+ def job_constantized
22
+ @worker_name.constantize
23
+ rescue
24
+ nil
25
+ end
26
+
27
+ def empty?
28
+ job_constantized.blank?
29
+ end
30
+
31
+ def escaped_name
32
+ CGI.escape worker_name
33
+ end
34
+
35
+ def include?(text)
36
+ return false unless job_constantized
37
+ downcased_text = text.downcase
38
+ worker_name.downcase.include?(downcased_text) ||
39
+ description.downcase.include?(downcased_text)
40
+ end
41
+ end
@@ -0,0 +1,38 @@
1
+ module SidekiqWebRunJobs
2
+ class JobRunner
3
+ attr_reader :worker_name
4
+
5
+ def self.execute!(*args)
6
+ new(*args).execute!
7
+ end
8
+
9
+ def initialize(worker_name:, worker_parameters:, perform_in: nil)
10
+ @worker_name = worker_name
11
+ @worker_parameters = worker_parameters
12
+ @perform_in = perform_in
13
+ end
14
+
15
+ def execute!
16
+ enqueue_worker
17
+ end
18
+
19
+ private def enqueue_worker
20
+ args = arguments_array
21
+ if @perform_in.present?
22
+ worker.perform_in(@perform_in.to_i.minutes, *args)
23
+ else
24
+ worker.perform_async(*args)
25
+ end
26
+ end
27
+ private def arguments_array
28
+ # {param_name: param_value,....}
29
+ @worker_parameters
30
+ .values # sidekiq perform_async only takes the values not named params
31
+ .map{|i| i.present? ? i : nil} # convert empty strings into nil
32
+ end
33
+
34
+ private def worker
35
+ worker_name.constantize
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,3 @@
1
+ module SidekiqWebRunJobs
2
+ VERSION = "1.0.1"
3
+ end
@@ -0,0 +1,55 @@
1
+ require_relative 'job_runner'
2
+ require_relative 'job_presenter'
3
+ require 'sidekiq/web' unless defined?(Sidekiq::Web)
4
+
5
+ module SidekiqWebRunJobs
6
+ module Web
7
+ VIEW_PATH = File.expand_path('../../../web/views', __FILE__)
8
+
9
+ def self.registered(app)
10
+ app.get '/run_jobs' do
11
+ job_names = SidekiqWebRunJobs.jobs
12
+ @count = (params["count"] || 25).to_i
13
+
14
+ @presented_jobs = job_names.map{ |job_name| JobPresenter.new(job_name) }.delete_if(&:empty?)
15
+ @total_size = @presented_jobs.size
16
+ @current_page = params["page"].to_i > 0 ? params["page"].to_i : 1
17
+ start_idx = @count * (@current_page - 1)
18
+ end_idx = @count * @current_page
19
+ @presented_jobs = @presented_jobs[start_idx..end_idx]
20
+ erb File.read(File.join(VIEW_PATH, 'web_jobs.erb'))
21
+ end
22
+
23
+ app.get '/run_jobs/:name/new' do
24
+ worker_name = CGI.unescape(params[:name])
25
+ @presented_job = JobPresenter.new(worker_name)
26
+ erb File.read(File.join(VIEW_PATH, 'new_web_jobs.erb'))
27
+ end
28
+
29
+ app.post '/run_jobs/:name/create' do
30
+ @worker_name = CGI.unescape(params[:name])
31
+ @job_id = JobRunner.execute!(
32
+ perform_in: params[:perform_in],
33
+ worker_parameters: params[:worker_parameters],
34
+ worker_name: @worker_name
35
+ )
36
+ erb File.read(File.join(VIEW_PATH, 'create_web_jobs.erb'))
37
+ end
38
+
39
+ app.post '/filter/run_jobs' do
40
+ search_with = params[:substr]
41
+ return redirect "#{root_path}run_jobs" unless search_with.present?
42
+ @count = (params["count"] || 25).to_i
43
+ @presented_jobs = SidekiqWebRunJobs.search_jobs(search_with)
44
+ @total_size = @presented_jobs.size
45
+
46
+ @current_page = params["page"].to_i > 0 ? params["page"].to_i : 1
47
+ start_idx = @count * (@current_page - 1)
48
+ end_idx = @count * @current_page
49
+ @presented_jobs = @presented_jobs[start_idx..end_idx]
50
+ erb File.read(File.join(VIEW_PATH, 'web_jobs.erb'))
51
+ end
52
+ end
53
+ end
54
+ end
55
+
@@ -0,0 +1,32 @@
1
+ require_relative 'lib/sidekiq_web_run_jobs/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "sidekiq-web-workers"
5
+ spec.version = SidekiqWebRunJobs::VERSION
6
+ spec.authors = ["Josh Etsenake"]
7
+ spec.email = ["etsenake@gmail.com"]
8
+
9
+ spec.summary = %q{Lightweight Job runner from sidekiq web ui}
10
+ spec.homepage = "https://github.com/etsenake/sidekiq_web_run_jobs"
11
+ spec.license = "MIT"
12
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.2.0")
13
+
14
+ spec.metadata["allowed_push_host"] = 'https://rubygems.org'
15
+
16
+ spec.metadata["homepage_uri"] = spec.homepage
17
+
18
+ # Specify which files should be added to the gem when it is released.
19
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
20
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
21
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
22
+ end
23
+ spec.bindir = "exe"
24
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
+ spec.require_paths = ["lib"]
26
+
27
+ spec.add_development_dependency 'rspec', '~> 2'
28
+ spec.add_development_dependency 'pry', "~> 0.1"
29
+
30
+ spec.add_dependency 'sidekiq', '~> 3'
31
+ spec.add_runtime_dependency 'rails', '~> 4.0'
32
+ end
@@ -0,0 +1,10 @@
1
+ en:
2
+ web_jobs: Sidekiq Web Workers
3
+ job_name: Worker Name
4
+ job_description: Worker Description
5
+ actions: Action
6
+ no_web_jobs: No workers found you can add ones in %{config_path}
7
+ submit: Queue Worker
8
+ successfully_queued: Your Worker Has been successfully enqueued
9
+ go_to_busy: Running workers
10
+ go_to_scheduled: Scheduled Workers
@@ -0,0 +1,8 @@
1
+ <div class="alert alert-success"><%= t('successfully_queued') %></div>
2
+ Worker Name: <%= @worker_name %>
3
+ <br/>
4
+ Job id: <%= @job_id %>
5
+ <div style='margin-top: 10px;'>
6
+ <a class="btn btn-default" href="<%= root_path %>busy?poll=true"><%= t('go_to_busy') %></a>
7
+ <a class="btn btn-danger" href="<%= root_path %>busy" style="color: white;"><%= t('go_to_scheduled') %></a>
8
+ </div>
@@ -0,0 +1,16 @@
1
+ <form class="form-horizontal" action="<%= root_path %>run_jobs/<%= @presented_job.escaped_name %>/create" method="post" autocomplete="off">
2
+ <%= csrf_tag %>
3
+ <a class="btn btn-default" href="<%= root_path %>run_jobs"><%= t('GoBack') %></a>
4
+ <div class="form-inline" style="margin-bottom: 10px;">
5
+ <label for="perform_in" style="min-width: 10em;">Perform In(minutes)</label>
6
+ <input type="text" name="perform_in" class="form-control">
7
+ </div>
8
+ <% @presented_job.method_arguments.each do |requirement, param_name| %>
9
+ <div class="form-inline" style="margin-bottom: 10px;">
10
+ <label for="worker_parameters[<%= param_name %>]" style="min-width: 10em;"><%= param_name.to_s %></label>
11
+ <input type="text" name="worker_parameters[<%= param_name %>]" class="form-control" required=<%=requirement == :req %>>
12
+ </div>
13
+ <% end %>
14
+ <br/>
15
+ <input name="commit" type="submit" value="<%= t('submit') %>" class="btn btn-primary" />
16
+ </form>
@@ -0,0 +1,39 @@
1
+ <header class="row">
2
+ <div class="col-sm-5">
3
+ <h3><%= t('web_jobs') %></h3>
4
+ </div>
5
+ <% if @presented_jobs.size > 0 && @total_size > @count %>
6
+ <div class="col-sm-4">
7
+ <%= erb :_paging, locals: { url: "#{root_path}run_jobs" } %>
8
+ </div>
9
+ <% end %>
10
+ <%= filtering('run_jobs') %>
11
+ </header>
12
+ <% if @presented_jobs.size > 0 %>
13
+ <div class="table_container">
14
+ <table class="table table-striped table-bordered">
15
+ <thead>
16
+ <tr>
17
+ <th><%= t('job_name') %></th>
18
+ <th><%= t('job_description') %></th>
19
+ <th><%= t('actions') %></th>
20
+ </tr>
21
+ </thead>
22
+ <% @presented_jobs.each do |presented_job| %>
23
+ <tr>
24
+ <td>
25
+ <%= presented_job.worker_name %>
26
+ </td>
27
+ <td>
28
+ <%= presented_job.description %>
29
+ </td>
30
+ <td>
31
+ <a href="<%= root_path %>run_jobs/<%=presented_job.escaped_name %>/new" class="btn btn-danger btn-xs" style="color: white;">Run Worker</a>
32
+ </td>
33
+ </tr>
34
+ <% end %>
35
+ </table>
36
+ </div>
37
+ <% else %>
38
+ <div class="alert alert-success"><%= t('no_web_jobs', config_path: "#{SidekiqWebRunJobs.config_path}") %></div>
39
+ <% end %>
metadata ADDED
@@ -0,0 +1,124 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sidekiq-web-workers
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Josh Etsenake
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-08-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: pry
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.1'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: sidekiq
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rails
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '4.0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '4.0'
69
+ description:
70
+ email:
71
+ - etsenake@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - ".travis.yml"
79
+ - CODE_OF_CONDUCT.md
80
+ - Gemfile
81
+ - Gemfile.lock
82
+ - LICENSE.txt
83
+ - README.md
84
+ - Rakefile
85
+ - bin/console
86
+ - bin/setup
87
+ - lib/sidekiq/job_runner.rb
88
+ - lib/sidekiq_web_run_jobs.rb
89
+ - lib/sidekiq_web_run_jobs/extensions/web.rb
90
+ - lib/sidekiq_web_run_jobs/job_presenter.rb
91
+ - lib/sidekiq_web_run_jobs/job_runner.rb
92
+ - lib/sidekiq_web_run_jobs/version.rb
93
+ - lib/sidekiq_web_run_jobs/web.rb
94
+ - sidekiq_web_run_jobs.gemspec
95
+ - web/locales/en.yml
96
+ - web/views/create_web_jobs.erb
97
+ - web/views/new_web_jobs.erb
98
+ - web/views/web_jobs.erb
99
+ homepage: https://github.com/etsenake/sidekiq_web_run_jobs
100
+ licenses:
101
+ - MIT
102
+ metadata:
103
+ allowed_push_host: https://rubygems.org
104
+ homepage_uri: https://github.com/etsenake/sidekiq_web_run_jobs
105
+ post_install_message:
106
+ rdoc_options: []
107
+ require_paths:
108
+ - lib
109
+ required_ruby_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: 2.2.0
114
+ required_rubygems_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ requirements: []
120
+ rubygems_version: 3.1.2
121
+ signing_key:
122
+ specification_version: 4
123
+ summary: Lightweight Job runner from sidekiq web ui
124
+ test_files: []