workhorse 1.0.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +43 -0
- data/README.md +4 -4
- data/Rakefile +0 -1
- data/VERSION +1 -1
- data/lib/active_job/queue_adapters/workhorse_adapter.rb +2 -2
- data/lib/generators/workhorse/templates/create_table_jobs.rb +2 -0
- data/lib/workhorse/daemon/shell_handler.rb +2 -2
- data/lib/workhorse/db_job.rb +1 -1
- data/lib/workhorse/enqueuer.rb +11 -4
- data/lib/workhorse/performer.rb +1 -0
- data/lib/workhorse/worker.rb +2 -2
- data/test/lib/db_schema.rb +2 -0
- data/test/workhorse/enqueuer_test.rb +9 -0
- data/workhorse.gemspec +3 -6
- metadata +2 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b800130ba7bb86469ae68e005113eec61b3dee92b546d1a74872d6f6b850901
|
4
|
+
data.tar.gz: 63decc2511cc7bcf6d216fe3e98bea5081e6b5a8a8069ac9a5501e0b8332871a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5e01457fccbe2e08db47413f6b9682a4048722f19877e6a54f7e1bcf73b21e59d92fe3575ada90405b0f287c0deb917b72b0259b988faceed0faf31a6e49ba1
|
7
|
+
data.tar.gz: 3edcb2482bc77266a934faf729314389561ff7c8d24aadc8ff25c2785248efdaa03aa705803ad86aeecf0c24bf7ac4ee4a6e8a2a112c0679b4a5bc181bdaea2e
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,48 @@
|
|
1
1
|
# Workhorse Changelog
|
2
2
|
|
3
|
+
## 1.2.2 - 2021-01-27
|
4
|
+
|
5
|
+
* Remove unused gem dependency to `schemacop`
|
6
|
+
|
7
|
+
## 1.2.1 - 2021-01-27
|
8
|
+
|
9
|
+
* Log job description (if given) when performing job
|
10
|
+
|
11
|
+
## 1.2.0 - 2021-01-27
|
12
|
+
|
13
|
+
* `Workhorse.enqueue_active_job`
|
14
|
+
* Change `perform_at` to a keyword arument
|
15
|
+
* Allow passing `:description` and `:queue`
|
16
|
+
|
17
|
+
Note that when upgrading, change:
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
# From
|
21
|
+
Workhorse.enqueue_active_job MyJob, 5.minutes.from_now
|
22
|
+
|
23
|
+
# To
|
24
|
+
Workhorse.enqueue_active_job MyJob, perform_at: 5.minutes.from_now
|
25
|
+
```
|
26
|
+
|
27
|
+
## 1.1.1 - 2021-01-19
|
28
|
+
|
29
|
+
* Remove deprecation warnings with Ruby 2.7
|
30
|
+
|
31
|
+
## 1.1.0 - 2020-12-24
|
32
|
+
|
33
|
+
* Add `description` column to `DbJob`.
|
34
|
+
|
35
|
+
If you're upgrading from a previous version, add the `description` column
|
36
|
+
to your `DbJob` table, e.g. with such a migration:
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
class AddDescriptionToWorkhorseDbJobs < ActiveRecord::Migration[6.0]
|
40
|
+
def change
|
41
|
+
add_column :jobs, :description, :string, after: :perform_at, null: true
|
42
|
+
end
|
43
|
+
end
|
44
|
+
```
|
45
|
+
|
3
46
|
## 1.0.1 - 2020-12-15
|
4
47
|
|
5
48
|
* Fix handling of empty pid files
|
data/README.md
CHANGED
@@ -81,7 +81,7 @@ GRANT execute ON DBMS_LOCK TO <schema-name>;
|
|
81
81
|
|
82
82
|
Workhorse can handle any jobs that support the `perform` method and are
|
83
83
|
serializable. To queue a basic job, use the static method `Workhorse.enqueue`.
|
84
|
-
You can optionally pass a queue name and a
|
84
|
+
You can optionally pass a queue name, a priority and a description (as a string).
|
85
85
|
|
86
86
|
```ruby
|
87
87
|
class MyJob
|
@@ -94,7 +94,7 @@ class MyJob
|
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
97
|
-
Workhorse.enqueue MyJob.new('John'), queue: :test, priority: 2
|
97
|
+
Workhorse.enqueue MyJob.new('John'), queue: :test, priority: 2, description: 'Basic Job'
|
98
98
|
```
|
99
99
|
|
100
100
|
### RailsOps operations
|
@@ -381,7 +381,7 @@ configuration or else using `self.queue_adapter` in a job class inheriting from
|
|
381
381
|
Per default, jobs remain in the database, no matter in which state. This can
|
382
382
|
eventually lead to a very large jobs database. You are advised to clean your
|
383
383
|
jobs database on a regular interval. Workhorse provides the job
|
384
|
-
`
|
384
|
+
`Workhorse::Jobs::CleanupSucceededJobs` for this purpose that cleans up all
|
385
385
|
succeeded jobs. You can run this using your scheduler in a specific interval.
|
386
386
|
|
387
387
|
## Caveats
|
@@ -421,4 +421,4 @@ Please consult the [FAQ](FAQ.md).
|
|
421
421
|
|
422
422
|
## Copyright
|
423
423
|
|
424
|
-
Copyright ©
|
424
|
+
Copyright © 2021 Sitrox. See `LICENSE` for further details.
|
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.2.2
|
@@ -14,8 +14,8 @@ module ActiveJob
|
|
14
14
|
Workhorse.enqueue_active_job(job)
|
15
15
|
end
|
16
16
|
|
17
|
-
def enqueue_at(job, timestamp) #:nodoc:
|
18
|
-
Workhorse.enqueue_active_job(job, timestamp)
|
17
|
+
def enqueue_at(job, timestamp = Time.now) #:nodoc:
|
18
|
+
Workhorse.enqueue_active_job(job, perform_at: timestamp)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Workhorse
|
2
2
|
class Daemon::ShellHandler
|
3
|
-
def self.run(options
|
3
|
+
def self.run(**options, &block)
|
4
4
|
unless ARGV.count == 1
|
5
5
|
usage
|
6
6
|
exit 99
|
@@ -10,7 +10,7 @@ module Workhorse
|
|
10
10
|
lockfile = File.open(lockfile_path, 'a')
|
11
11
|
lockfile.flock(File::LOCK_EX || File::LOCK_NB)
|
12
12
|
|
13
|
-
daemon = Workhorse::Daemon.new(options, &block)
|
13
|
+
daemon = Workhorse::Daemon.new(**options, &block)
|
14
14
|
|
15
15
|
begin
|
16
16
|
case ARGV.first
|
data/lib/workhorse/db_job.rb
CHANGED
data/lib/workhorse/enqueuer.rb
CHANGED
@@ -1,20 +1,27 @@
|
|
1
1
|
module Workhorse
|
2
2
|
module Enqueuer
|
3
3
|
# Enqueue any object that is serializable and has a `perform` method
|
4
|
-
def enqueue(job, queue: nil, priority: 0, perform_at: Time.now)
|
4
|
+
def enqueue(job, queue: nil, priority: 0, perform_at: Time.now, description: nil)
|
5
5
|
return DbJob.create!(
|
6
6
|
queue: queue,
|
7
7
|
priority: priority,
|
8
8
|
perform_at: perform_at,
|
9
|
+
description: description,
|
9
10
|
handler: Marshal.dump(job)
|
10
11
|
)
|
11
12
|
end
|
12
13
|
|
13
14
|
# Enqueue an ActiveJob job
|
14
|
-
def enqueue_active_job(job, perform_at
|
15
|
+
def enqueue_active_job(job, perform_at: Time.now, queue: nil, description: nil)
|
15
16
|
wrapper_job = Jobs::RunActiveJob.new(job.serialize)
|
16
|
-
queue
|
17
|
-
db_job = enqueue(
|
17
|
+
queue ||= job.queue_name if job.queue_name.present?
|
18
|
+
db_job = enqueue(
|
19
|
+
wrapper_job,
|
20
|
+
queue: queue,
|
21
|
+
priority: job.priority || 0,
|
22
|
+
perform_at: Time.at(perform_at),
|
23
|
+
description: description
|
24
|
+
)
|
18
25
|
job.provider_job_id = db_job.id
|
19
26
|
return db_job
|
20
27
|
end
|
data/lib/workhorse/performer.rb
CHANGED
@@ -59,6 +59,7 @@ module Workhorse
|
|
59
59
|
# Deserialize and perform job
|
60
60
|
# ---------------------------------------------------------------
|
61
61
|
log 'Performing', :info
|
62
|
+
log "Description: #{@db_job.description}", :info unless @db_job.description.blank?
|
62
63
|
|
63
64
|
if Workhorse.perform_jobs_in_tx
|
64
65
|
Workhorse.tx_callback.call do
|
data/lib/workhorse/worker.rb
CHANGED
@@ -13,8 +13,8 @@ module Workhorse
|
|
13
13
|
|
14
14
|
# Instantiates and starts a new worker with the given arguments and then
|
15
15
|
# waits for its completion (i.e. an interrupt).
|
16
|
-
def self.start_and_wait(
|
17
|
-
worker = new(
|
16
|
+
def self.start_and_wait(**args)
|
17
|
+
worker = new(**args)
|
18
18
|
worker.start
|
19
19
|
worker.wait
|
20
20
|
end
|
data/test/lib/db_schema.rb
CHANGED
@@ -33,6 +33,15 @@ class Workhorse::EnqueuerTest < WorkhorseTest
|
|
33
33
|
assert_equal 1, Workhorse::DbJob.first.priority
|
34
34
|
end
|
35
35
|
|
36
|
+
def test_with_description
|
37
|
+
assert_equal 0, Workhorse::DbJob.all.count
|
38
|
+
Workhorse.enqueue BasicJob.new, description: 'Lorem ipsum'
|
39
|
+
assert_equal 1, Workhorse::DbJob.all.count
|
40
|
+
|
41
|
+
db_job = Workhorse::DbJob.first
|
42
|
+
assert_equal 'Lorem ipsum', db_job.description
|
43
|
+
end
|
44
|
+
|
36
45
|
def test_op
|
37
46
|
Workhorse.enqueue_op DummyRailsOpsOp, { queue: :q1 }, foo: :bar
|
38
47
|
|
data/workhorse.gemspec
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: workhorse 1.
|
2
|
+
# stub: workhorse 1.2.2 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "workhorse".freeze
|
6
|
-
s.version = "1.
|
6
|
+
s.version = "1.2.2"
|
7
7
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
9
9
|
s.require_paths = ["lib".freeze]
|
10
10
|
s.authors = ["Sitrox".freeze]
|
11
|
-
s.date = "
|
11
|
+
s.date = "2021-01-27"
|
12
12
|
s.files = [".gitignore".freeze, ".releaser_config".freeze, ".rubocop.yml".freeze, ".travis.yml".freeze, "CHANGELOG.md".freeze, "FAQ.md".freeze, "Gemfile".freeze, "LICENSE".freeze, "README.md".freeze, "RUBY_VERSION".freeze, "Rakefile".freeze, "VERSION".freeze, "bin/rubocop".freeze, "lib/active_job/queue_adapters/workhorse_adapter.rb".freeze, "lib/generators/workhorse/install_generator.rb".freeze, "lib/generators/workhorse/templates/bin/workhorse.rb".freeze, "lib/generators/workhorse/templates/config/initializers/workhorse.rb".freeze, "lib/generators/workhorse/templates/create_table_jobs.rb".freeze, "lib/workhorse.rb".freeze, "lib/workhorse/daemon.rb".freeze, "lib/workhorse/daemon/shell_handler.rb".freeze, "lib/workhorse/db_job.rb".freeze, "lib/workhorse/enqueuer.rb".freeze, "lib/workhorse/jobs/cleanup_succeeded_jobs.rb".freeze, "lib/workhorse/jobs/detect_stale_jobs_job.rb".freeze, "lib/workhorse/jobs/run_active_job.rb".freeze, "lib/workhorse/jobs/run_rails_op.rb".freeze, "lib/workhorse/performer.rb".freeze, "lib/workhorse/poller.rb".freeze, "lib/workhorse/pool.rb".freeze, "lib/workhorse/scoped_env.rb".freeze, "lib/workhorse/worker.rb".freeze, "test/active_job/queue_adapters/workhorse_adapter_test.rb".freeze, "test/lib/db_schema.rb".freeze, "test/lib/jobs.rb".freeze, "test/lib/test_helper.rb".freeze, "test/workhorse/db_job_test.rb".freeze, "test/workhorse/enqueuer_test.rb".freeze, "test/workhorse/performer_test.rb".freeze, "test/workhorse/poller_test.rb".freeze, "test/workhorse/pool_test.rb".freeze, "test/workhorse/worker_test.rb".freeze, "workhorse.gemspec".freeze]
|
13
13
|
s.rubygems_version = "3.0.3".freeze
|
14
14
|
s.summary = "Multi-threaded job backend with database queuing for ruby.".freeze
|
@@ -29,7 +29,6 @@ Gem::Specification.new do |s|
|
|
29
29
|
s.add_development_dependency(%q<pry>.freeze, [">= 0"])
|
30
30
|
s.add_runtime_dependency(%q<activesupport>.freeze, [">= 0"])
|
31
31
|
s.add_runtime_dependency(%q<activerecord>.freeze, [">= 0"])
|
32
|
-
s.add_runtime_dependency(%q<schemacop>.freeze, ["~> 2.0"])
|
33
32
|
s.add_runtime_dependency(%q<concurrent-ruby>.freeze, [">= 0"])
|
34
33
|
else
|
35
34
|
s.add_dependency(%q<bundler>.freeze, [">= 0"])
|
@@ -43,7 +42,6 @@ Gem::Specification.new do |s|
|
|
43
42
|
s.add_dependency(%q<pry>.freeze, [">= 0"])
|
44
43
|
s.add_dependency(%q<activesupport>.freeze, [">= 0"])
|
45
44
|
s.add_dependency(%q<activerecord>.freeze, [">= 0"])
|
46
|
-
s.add_dependency(%q<schemacop>.freeze, ["~> 2.0"])
|
47
45
|
s.add_dependency(%q<concurrent-ruby>.freeze, [">= 0"])
|
48
46
|
end
|
49
47
|
else
|
@@ -58,7 +56,6 @@ Gem::Specification.new do |s|
|
|
58
56
|
s.add_dependency(%q<pry>.freeze, [">= 0"])
|
59
57
|
s.add_dependency(%q<activesupport>.freeze, [">= 0"])
|
60
58
|
s.add_dependency(%q<activerecord>.freeze, [">= 0"])
|
61
|
-
s.add_dependency(%q<schemacop>.freeze, ["~> 2.0"])
|
62
59
|
s.add_dependency(%q<concurrent-ruby>.freeze, [">= 0"])
|
63
60
|
end
|
64
61
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: workhorse
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sitrox
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -164,20 +164,6 @@ dependencies:
|
|
164
164
|
- - ">="
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: '0'
|
167
|
-
- !ruby/object:Gem::Dependency
|
168
|
-
name: schemacop
|
169
|
-
requirement: !ruby/object:Gem::Requirement
|
170
|
-
requirements:
|
171
|
-
- - "~>"
|
172
|
-
- !ruby/object:Gem::Version
|
173
|
-
version: '2.0'
|
174
|
-
type: :runtime
|
175
|
-
prerelease: false
|
176
|
-
version_requirements: !ruby/object:Gem::Requirement
|
177
|
-
requirements:
|
178
|
-
- - "~>"
|
179
|
-
- !ruby/object:Gem::Version
|
180
|
-
version: '2.0'
|
181
167
|
- !ruby/object:Gem::Dependency
|
182
168
|
name: concurrent-ruby
|
183
169
|
requirement: !ruby/object:Gem::Requirement
|