hard_worker 0.0.3 → 0.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/.gitignore +3 -1
- data/.rspec +1 -0
- data/.rubocop.yml +13 -0
- data/CHANGELOG.md +11 -1
- data/Gemfile +3 -0
- data/Gemfile.lock +133 -1
- data/README.md +48 -1
- data/bin/bundle +3 -0
- data/bin/hard_worker +32 -1
- data/dummy/Rakefile +8 -0
- data/dummy/app/assets/config/manifest.js +3 -0
- data/dummy/app/assets/images/.keep +0 -0
- data/dummy/app/assets/stylesheets/application.css +15 -0
- data/dummy/app/channels/application_cable/channel.rb +6 -0
- data/dummy/app/channels/application_cable/connection.rb +6 -0
- data/dummy/app/controllers/application_controller.rb +5 -0
- data/dummy/app/controllers/concerns/.keep +0 -0
- data/dummy/app/helpers/application_helper.rb +4 -0
- data/dummy/app/javascript/packs/application.js +15 -0
- data/dummy/app/jobs/application_job.rb +9 -0
- data/dummy/app/mailers/application_mailer.rb +6 -0
- data/dummy/app/models/application_record.rb +5 -0
- data/dummy/app/models/concerns/.keep +0 -0
- data/dummy/app/models/user.rb +2 -0
- data/dummy/app/views/application/index.html.erb +4 -0
- data/dummy/app/views/layouts/application.html.erb +15 -0
- data/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/dummy/bin/rails +6 -0
- data/dummy/bin/rake +6 -0
- data/dummy/bin/setup +35 -0
- data/dummy/config.ru +8 -0
- data/dummy/config/application.rb +23 -0
- data/dummy/config/boot.rb +7 -0
- data/dummy/config/cable.yml +10 -0
- data/dummy/config/credentials.yml.enc +1 -0
- data/dummy/config/database.yml +25 -0
- data/dummy/config/environment.rb +7 -0
- data/dummy/config/environments/development.rb +78 -0
- data/dummy/config/environments/production.rb +122 -0
- data/dummy/config/environments/test.rb +51 -0
- data/dummy/config/initializers/application_controller_renderer.rb +9 -0
- data/dummy/config/initializers/backtrace_silencers.rb +10 -0
- data/dummy/config/initializers/content_security_policy.rb +29 -0
- data/dummy/config/initializers/cookies_serializer.rb +7 -0
- data/dummy/config/initializers/filter_parameter_logging.rb +8 -0
- data/dummy/config/initializers/inflections.rb +17 -0
- data/dummy/config/initializers/mime_types.rb +5 -0
- data/dummy/config/initializers/permissions_policy.rb +12 -0
- data/dummy/config/initializers/wrap_parameters.rb +16 -0
- data/dummy/config/locales/en.yml +33 -0
- data/dummy/config/master.key +1 -0
- data/dummy/config/puma.rb +45 -0
- data/dummy/config/routes.rb +5 -0
- data/dummy/config/storage.yml +34 -0
- data/dummy/db/migrate/20210613015406_create_users.rb +10 -0
- data/dummy/db/production.sqlite3 +0 -0
- data/dummy/db/schema.rb +20 -0
- data/dummy/db/test.sqlite3 +0 -0
- data/dummy/lib/assets/.keep +0 -0
- data/dummy/log/.keep +0 -0
- data/dummy/log/development.log +0 -0
- data/dummy/log/production.log +3 -0
- data/dummy/log/test.log +31 -0
- data/dummy/public/404.html +67 -0
- data/dummy/public/422.html +67 -0
- data/dummy/public/500.html +66 -0
- data/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/dummy/public/apple-touch-icon.png +0 -0
- data/dummy/public/favicon.ico +0 -0
- data/dummy/storage/.keep +0 -0
- data/dummy/tmp/.keep +0 -0
- data/dummy/tmp/development_secret.txt +1 -0
- data/dummy/tmp/pids/.keep +0 -0
- data/dummy/tmp/storage/.keep +0 -0
- data/{hardwordker.gemspec → hard_worker.gemspec} +7 -0
- data/lib/hard_worker.rb +87 -9
- data/lib/hard_worker/client.rb +16 -0
- data/lib/hard_worker/rails.rb +5 -0
- data/lib/hard_worker/version.rb +1 -1
- data/lib/hard_worker/worker.rb +1 -1
- metadata +91 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 61d96fa08d1068e7bc79f2eea45d9cb78ba20773f343be2ddb0df5e598accc82
|
4
|
+
data.tar.gz: 2093f3e18019a457e32fb160ce503f8aae73c2e728d0e7a5b55c18a5a4d7bf4e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e073fadacdb5099ad0c507465cd0c291d6290cbb66d1387e3204bcb7a0d147e05cffd02cbd1eb5e3bc0bf323c83fe109f4d4911d44526ddbd36abc5fc05ba2b0
|
7
|
+
data.tar.gz: 42b0a7707ac39012fcbd1ee28e7ee5aa3ca6fa4169581e48ae4262466ef3ef15bda9e9bd1a81e9bb1917bfe796a264a770e4ec6d0e429fe11f667f386de5eb4f
|
data/.gitignore
CHANGED
data/.rspec
CHANGED
data/.rubocop.yml
CHANGED
@@ -22,5 +22,18 @@ Style/AsciiComments:
|
|
22
22
|
Style/ClassVars:
|
23
23
|
Enabled: false
|
24
24
|
|
25
|
+
Style/Documentation:
|
26
|
+
Enabled: false
|
27
|
+
|
28
|
+
Style/GlobalVars:
|
29
|
+
Enabled: false
|
30
|
+
|
31
|
+
Style/BlockDelimiters:
|
32
|
+
EnforcedStyle: braces_for_chaining
|
33
|
+
|
34
|
+
Metrics/BlockLength:
|
35
|
+
Exclude:
|
36
|
+
- 'spec/**/*.rb'
|
37
|
+
|
25
38
|
Security/YAMLLoad:
|
26
39
|
Enabled: false
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
Rails support!
|
4
|
+
Need a better way to find Rails config, going to release 0.1.0 after that.
|
5
|
+
Going to change the name of the gem to something a bit more original than HardWorker.
|
6
|
+
(HardWorker is already in use in Sidekiq documentation)
|
3
7
|
## [0.0.1] - 2021-07-15
|
4
8
|
|
5
9
|
- Initial release! :tada:
|
@@ -13,4 +17,10 @@ Things are almost working. You can enqueue jobs! That should be more than enough
|
|
13
17
|
## [0.0.3] - 2021-07-16
|
14
18
|
|
15
19
|
- YAML Marshalled queue! So now the queue stays in memory even if restarted. Though kill and term signals still need catching.. that is not done yet.
|
16
|
-
- Also, now you can use classes! As long as the class has a perform-method.
|
20
|
+
- Also, now you can use classes! As long as the class has a perform-method.
|
21
|
+
|
22
|
+
## [0.0.4] - 2021-07-24
|
23
|
+
|
24
|
+
- Rails support!
|
25
|
+
- Banner (for Belated though...)
|
26
|
+
- Final release, as the name of this gem is going to change to Belated.
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,19 +1,134 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
hard_worker (0.0.
|
4
|
+
hard_worker (0.0.4)
|
5
5
|
drb
|
6
|
+
dry-configurable
|
6
7
|
|
7
8
|
GEM
|
8
9
|
remote: https://rubygems.org/
|
9
10
|
specs:
|
11
|
+
actioncable (6.1.4)
|
12
|
+
actionpack (= 6.1.4)
|
13
|
+
activesupport (= 6.1.4)
|
14
|
+
nio4r (~> 2.0)
|
15
|
+
websocket-driver (>= 0.6.1)
|
16
|
+
actionmailbox (6.1.4)
|
17
|
+
actionpack (= 6.1.4)
|
18
|
+
activejob (= 6.1.4)
|
19
|
+
activerecord (= 6.1.4)
|
20
|
+
activestorage (= 6.1.4)
|
21
|
+
activesupport (= 6.1.4)
|
22
|
+
mail (>= 2.7.1)
|
23
|
+
actionmailer (6.1.4)
|
24
|
+
actionpack (= 6.1.4)
|
25
|
+
actionview (= 6.1.4)
|
26
|
+
activejob (= 6.1.4)
|
27
|
+
activesupport (= 6.1.4)
|
28
|
+
mail (~> 2.5, >= 2.5.4)
|
29
|
+
rails-dom-testing (~> 2.0)
|
30
|
+
actionpack (6.1.4)
|
31
|
+
actionview (= 6.1.4)
|
32
|
+
activesupport (= 6.1.4)
|
33
|
+
rack (~> 2.0, >= 2.0.9)
|
34
|
+
rack-test (>= 0.6.3)
|
35
|
+
rails-dom-testing (~> 2.0)
|
36
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
37
|
+
actiontext (6.1.4)
|
38
|
+
actionpack (= 6.1.4)
|
39
|
+
activerecord (= 6.1.4)
|
40
|
+
activestorage (= 6.1.4)
|
41
|
+
activesupport (= 6.1.4)
|
42
|
+
nokogiri (>= 1.8.5)
|
43
|
+
actionview (6.1.4)
|
44
|
+
activesupport (= 6.1.4)
|
45
|
+
builder (~> 3.1)
|
46
|
+
erubi (~> 1.4)
|
47
|
+
rails-dom-testing (~> 2.0)
|
48
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
49
|
+
activejob (6.1.4)
|
50
|
+
activesupport (= 6.1.4)
|
51
|
+
globalid (>= 0.3.6)
|
52
|
+
activemodel (6.1.4)
|
53
|
+
activesupport (= 6.1.4)
|
54
|
+
activerecord (6.1.4)
|
55
|
+
activemodel (= 6.1.4)
|
56
|
+
activesupport (= 6.1.4)
|
57
|
+
activestorage (6.1.4)
|
58
|
+
actionpack (= 6.1.4)
|
59
|
+
activejob (= 6.1.4)
|
60
|
+
activerecord (= 6.1.4)
|
61
|
+
activesupport (= 6.1.4)
|
62
|
+
marcel (~> 1.0.0)
|
63
|
+
mini_mime (>= 1.1.0)
|
64
|
+
activesupport (6.1.4)
|
65
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
66
|
+
i18n (>= 1.6, < 2)
|
67
|
+
minitest (>= 5.1)
|
68
|
+
tzinfo (~> 2.0)
|
69
|
+
zeitwerk (~> 2.3)
|
10
70
|
ast (2.4.2)
|
71
|
+
builder (3.2.4)
|
11
72
|
byebug (11.1.3)
|
73
|
+
concurrent-ruby (1.1.9)
|
74
|
+
crass (1.0.6)
|
12
75
|
diff-lcs (1.4.4)
|
13
76
|
drb (2.0.4)
|
77
|
+
dry-configurable (0.12.1)
|
78
|
+
concurrent-ruby (~> 1.0)
|
79
|
+
dry-core (~> 0.5, >= 0.5.0)
|
80
|
+
dry-core (0.7.1)
|
81
|
+
concurrent-ruby (~> 1.0)
|
82
|
+
erubi (1.10.0)
|
83
|
+
globalid (0.4.2)
|
84
|
+
activesupport (>= 4.2.0)
|
85
|
+
i18n (1.8.10)
|
86
|
+
concurrent-ruby (~> 1.0)
|
87
|
+
loofah (2.10.0)
|
88
|
+
crass (~> 1.0.2)
|
89
|
+
nokogiri (>= 1.5.9)
|
90
|
+
mail (2.7.1)
|
91
|
+
mini_mime (>= 0.1.1)
|
92
|
+
marcel (1.0.1)
|
93
|
+
method_source (1.0.0)
|
94
|
+
mini_mime (1.1.0)
|
95
|
+
minitest (5.14.4)
|
96
|
+
nio4r (2.5.7)
|
97
|
+
nokogiri (1.11.7-x86_64-linux)
|
98
|
+
racc (~> 1.4)
|
14
99
|
parallel (1.20.1)
|
15
100
|
parser (3.0.2.0)
|
16
101
|
ast (~> 2.4.1)
|
102
|
+
racc (1.5.2)
|
103
|
+
rack (2.2.3)
|
104
|
+
rack-test (1.1.0)
|
105
|
+
rack (>= 1.0, < 3)
|
106
|
+
rails (6.1.4)
|
107
|
+
actioncable (= 6.1.4)
|
108
|
+
actionmailbox (= 6.1.4)
|
109
|
+
actionmailer (= 6.1.4)
|
110
|
+
actionpack (= 6.1.4)
|
111
|
+
actiontext (= 6.1.4)
|
112
|
+
actionview (= 6.1.4)
|
113
|
+
activejob (= 6.1.4)
|
114
|
+
activemodel (= 6.1.4)
|
115
|
+
activerecord (= 6.1.4)
|
116
|
+
activestorage (= 6.1.4)
|
117
|
+
activesupport (= 6.1.4)
|
118
|
+
bundler (>= 1.15.0)
|
119
|
+
railties (= 6.1.4)
|
120
|
+
sprockets-rails (>= 2.0.0)
|
121
|
+
rails-dom-testing (2.0.3)
|
122
|
+
activesupport (>= 4.2.0)
|
123
|
+
nokogiri (>= 1.6)
|
124
|
+
rails-html-sanitizer (1.3.0)
|
125
|
+
loofah (~> 2.3)
|
126
|
+
railties (6.1.4)
|
127
|
+
actionpack (= 6.1.4)
|
128
|
+
activesupport (= 6.1.4)
|
129
|
+
method_source
|
130
|
+
rake (>= 0.13)
|
131
|
+
thor (~> 1.0)
|
17
132
|
rainbow (3.0.0)
|
18
133
|
rake (13.0.6)
|
19
134
|
regexp_parser (2.1.1)
|
@@ -43,7 +158,22 @@ GEM
|
|
43
158
|
rubocop-ast (1.7.0)
|
44
159
|
parser (>= 3.0.1.1)
|
45
160
|
ruby-progressbar (1.11.0)
|
161
|
+
sprockets (4.0.2)
|
162
|
+
concurrent-ruby (~> 1.0)
|
163
|
+
rack (> 1, < 3)
|
164
|
+
sprockets-rails (3.2.2)
|
165
|
+
actionpack (>= 4.0)
|
166
|
+
activesupport (>= 4.0)
|
167
|
+
sprockets (>= 3.0.0)
|
168
|
+
sqlite3 (1.4.2)
|
169
|
+
thor (1.1.0)
|
170
|
+
tzinfo (2.0.4)
|
171
|
+
concurrent-ruby (~> 1.0)
|
46
172
|
unicode-display_width (2.0.0)
|
173
|
+
websocket-driver (0.7.5)
|
174
|
+
websocket-extensions (>= 0.1.0)
|
175
|
+
websocket-extensions (0.1.5)
|
176
|
+
zeitwerk (2.4.2)
|
47
177
|
|
48
178
|
PLATFORMS
|
49
179
|
x86_64-linux
|
@@ -51,9 +181,11 @@ PLATFORMS
|
|
51
181
|
DEPENDENCIES
|
52
182
|
byebug
|
53
183
|
hard_worker!
|
184
|
+
rails (>= 6.1.3)
|
54
185
|
rake (~> 13.0)
|
55
186
|
rspec (~> 3.0)
|
56
187
|
rubocop (~> 1.7)
|
188
|
+
sqlite3
|
57
189
|
|
58
190
|
BUNDLED WITH
|
59
191
|
2.2.17
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Hardworker
|
2
2
|
|
3
|
+
[](https://www.codefactor.io/repository/github/sampokuokkanen/hard_worker) [](https://badge.fury.io/rb/hard_worker)
|
4
|
+
|
3
5
|
This is HardWorker, a new Ruby backend job library! It supports running procs and classes in the background.
|
4
6
|
~~Also, you lose all jobs if you restart the process.~~ It now uses YAML to load the queue into a file, which it then calls at startup to find the previous jobs.
|
5
7
|
|
@@ -8,7 +10,9 @@ It uses dRuby to do the communication! Which is absolute great. No need for Redi
|
|
8
10
|
TODO LIST:
|
9
11
|
- ~~Marshal the job queue into a file so you don't lose all progress~~
|
10
12
|
(Ended up using YAML)
|
11
|
-
- Support Rails
|
13
|
+
- ~~Support Rails~~ (Supported!)
|
14
|
+
- ~~Parse options from command line, eg. `--workers 10`~~(Done!)
|
15
|
+
- Maybe support ActiveJob?
|
12
16
|
- Have a web UI
|
13
17
|
- Do some performance testing
|
14
18
|
- Add a section telling people to use Sidekiq if they can
|
@@ -62,7 +66,50 @@ dummy.queue.push(proc { 2 / 1 })
|
|
62
66
|
dummy.queue.push(DumDum.new)
|
63
67
|
```
|
64
68
|
|
69
|
+
Hardworker runs on localhost, port 8788. Should probably make that a value you can change...
|
70
|
+
|
71
|
+
## Rails
|
72
|
+
|
73
|
+
Usage with Rails:
|
74
|
+
First, start up HardWorker.
|
75
|
+
Then,
|
76
|
+
```ruby
|
77
|
+
$client = HardWorker::Client.new
|
78
|
+
```
|
79
|
+
|
80
|
+
and you can use the client!
|
81
|
+
Call
|
82
|
+
|
83
|
+
```ruby
|
84
|
+
$client.perform_belated(job)
|
85
|
+
```
|
86
|
+
If you want to pass a job to HardWorker.
|
87
|
+
|
88
|
+
# Settings
|
89
|
+
Configuring HardWorker:
|
90
|
+
|
91
|
+
```ruby
|
92
|
+
HardWorker.configure do |config|
|
93
|
+
config.rails = false # default is true
|
94
|
+
config.rails_path = # './dummy' default is '.'
|
95
|
+
config.connect = false # Connect to dRuby, default is true, useful for testing only
|
96
|
+
config.workers = 2 # default is 1
|
97
|
+
end
|
98
|
+
```
|
99
|
+
|
100
|
+
From command line:
|
101
|
+
|
102
|
+
$ bundle exec hard_worker --rails=true
|
103
|
+
|
104
|
+
Use Rails or not.
|
105
|
+
|
106
|
+
$ bundle exec hard_worker --rails_path=/my_rails_project
|
107
|
+
|
108
|
+
Path to Rails project.
|
109
|
+
|
110
|
+
$ bundle exec hard_worker --workers=10
|
65
111
|
|
112
|
+
Number of workers.
|
66
113
|
## Development
|
67
114
|
|
68
115
|
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.
|
data/bin/bundle
ADDED
data/bin/hard_worker
CHANGED
@@ -1,7 +1,38 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
+
$TESTING = false
|
4
5
|
$LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../lib")
|
5
6
|
require 'hard_worker'
|
7
|
+
require 'optparse'
|
8
|
+
require 'byebug'
|
6
9
|
|
7
|
-
|
10
|
+
OptionParser.new do |opts|
|
11
|
+
opts.banner = 'Usage: hard_worker [options]'
|
12
|
+
|
13
|
+
opts.separator ''
|
14
|
+
opts.separator 'Options:'
|
15
|
+
|
16
|
+
opts.on('-r=RAILS', '--rails=RAILS', 'Load Rails or not, default true') do |rails|
|
17
|
+
HardWorker.config.rails = rails == 'true'
|
18
|
+
end
|
19
|
+
|
20
|
+
opts.on('-r_path=PATH', '--rails_path=PATH', 'Path to Rails') do |path|
|
21
|
+
HardWorker.config.rails_path = path
|
22
|
+
end
|
23
|
+
|
24
|
+
opts.on('-w=WORKERS', '--workers=WORKERS', 'Number of workers, default 1') do |workers|
|
25
|
+
HardWorker.config.workers = workers.to_i
|
26
|
+
end
|
27
|
+
|
28
|
+
opts.on('-e=ENV', '--env=ENV', 'Environment, default development') do |env|
|
29
|
+
HardWorker.config.env = env
|
30
|
+
end
|
31
|
+
|
32
|
+
opts.on('-c=CONNECT', '--connect=CONNECT', 'Start dRuby connection, default true') do |connect|
|
33
|
+
HardWorker.config.connect = connect == 'true'
|
34
|
+
end
|
35
|
+
end.parse!
|
36
|
+
|
37
|
+
instance = HardWorker.instance
|
38
|
+
instance.start
|
data/dummy/Rakefile
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
4
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
5
|
+
|
6
|
+
require_relative 'config/application'
|
7
|
+
|
8
|
+
Rails.application.load_tasks
|
File without changes
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
10
|
+
* files in this directory. Styles in this file should be added after the last require_* statement.
|
11
|
+
* It is generally better to create a new file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
File without changes
|
@@ -0,0 +1,15 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file. JavaScript code in this file should be added after the last require_* statement.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require rails-ujs
|
14
|
+
//= require activestorage
|
15
|
+
//= require_tree .
|