workhorse 0.3.6 → 0.3.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4a4f3666d9865ea9578e5bb735c0889a3701be869f07fc52c971777e41dbae4e
4
- data.tar.gz: 3fca0dcf3192f1bc954c8963eb272e4aadcba4a6d2616c57600fd5ae2003a3a0
3
+ metadata.gz: 3d89b887e87a7aad1c081461bd76a98dbf8b0e6f6b0aa6e221936d4d2fe7d745
4
+ data.tar.gz: 1786cfab5d08fd0c6d51158b2241db9766653e1410e391094b65587f17317fe5
5
5
  SHA512:
6
- metadata.gz: c8437d30f0f38fee5cf2c709642af4a4a85439138ba4fbf07935a18577fdde01c1bcccdd14e84579cefee141393b878669702a835852f5ffddd9e2b39ad73699
7
- data.tar.gz: d73c6f4432a64d9e26b1b010dc88ac5c9751cb7a7a99bce2b885e17f0b0967c540704a1d6af4a9cb4bd7e2b59dc89648a98c3de305090fa7d91ed11259c2c5aa
6
+ metadata.gz: d7563ef29ea4dde18f0b146f905296c0653710d04c0c539a7f50d3d86df48e8a2e82e97e478c46f884e812362d4332287630a44d901ff52e591232b5dceac266
7
+ data.tar.gz: 7727e7339918c20ab48c719174c4c90484dc723052a141c7bb1dd717e51adda9e6ff2fa622ce2fc555b7725ba9f08eaf369fb0019db5c821c88a3691a46ee1ce
data/.travis.yml CHANGED
@@ -8,5 +8,5 @@ before_install:
8
8
  - mysql -e 'CREATE DATABASE workhorse;'
9
9
  script:
10
10
  - bundle install
11
- - bundle exec rake test
11
+ - bundle exec rake test TESTOPTS='--verbose'
12
12
  - bundle exec rubocop
data/CHANGELOG.md CHANGED
@@ -1,31 +1,35 @@
1
1
  # Workhorse Change log
2
2
 
3
- ## 0.3.6 - 2018-11-14
3
+ ## 0.3.7 2018-12-17
4
+
5
+ * Fixed Oracle DB compatibility issues for jobs in multiple queues
6
+
7
+ ## 0.3.6 – 2018-11-14
4
8
 
5
9
  * Makes sure all exceptions are caught and handled properly, not only exceptions
6
10
  deriving from `StandardError`. In previous releases, this prevented some
7
11
  exceptions like syntax errors to be handled properly.
8
12
 
9
- ## 0.3.5 - 2018-10-22
13
+ ## 0.3.5 2018-10-22
10
14
 
11
15
  * Adds global callback `on_exception` that allows custom exception handling /
12
16
  exception notification.
13
17
 
14
- ## 0.3.4 - 2018-09-24
18
+ ## 0.3.4 2018-09-24
15
19
 
16
- * *Fixes #14
20
+ * Fixes #14
17
21
 
18
22
  * Fixes crucial bug where multiple jobs of the same queue could be executed
19
23
  simultaneously.
20
24
 
21
25
  * Makes `Workhorse::DbJob` attributes accessible for earlier versions of rails.
22
26
 
23
- ## 0.3.3 - 2018-02-26
27
+ ## 0.3.3 2018-02-26
24
28
 
25
29
  * Adds missing require for `concurrent` library that is required in some
26
30
  versions of Rails
27
31
 
28
- ## 0.3.2 - 2018-02-23
32
+ ## 0.3.2 2018-02-23
29
33
 
30
34
  * Fixes a migration bug
31
35
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.6
1
+ 0.3.7
@@ -95,7 +95,7 @@ module Workhorse
95
95
  union_parts = []
96
96
  valid_queues.each do |queue|
97
97
  # Start with a fresh select, as we now know the allowed queues
98
- select = valid_ordered_select
98
+ select = valid_ordered_select_id
99
99
  select = select.where(table[:queue].eq(queue))
100
100
 
101
101
  # Get the maximum amount possible for no-queue jobs. This gives us the
@@ -110,14 +110,17 @@ module Workhorse
110
110
 
111
111
  # Combine the jobs of each queue in a giant UNION chain. Arel does not
112
112
  # support this directly, as it does not generate parentheses around the
113
- # subselects.
114
- # Furthermore, add the alias directly instead of using Arel `as`, because
115
- # it uses the keyword 'AS' in SQL generated for Oracle, which is invalid
116
- # for table aliases.
113
+ # subselects. The parentheses are necessary because of the order clauses
114
+ # contained within.
115
+ # Additionally, each of the subselects and the final union select is given
116
+ # an alias to comply with MySQL requirements.
117
+ # These aliases are added directly instead of using Arel `as`, because it
118
+ # uses the keyword 'AS' in SQL generated for Oracle, which is invalid for
119
+ # table aliases.
117
120
  union_query_sql = '('
118
- union_query_sql += '(' + union_parts.shift.to_sql + ')'
119
- union_parts.each do |part|
120
- union_query_sql += ' UNION (' + part.to_sql + ')'
121
+ union_query_sql += 'SELECT * FROM (' + union_parts.shift.to_sql + ') union_0'
122
+ union_parts.each_with_index do |part, idx|
123
+ union_query_sql += ' UNION SELECT * FROM (' + part.to_sql + ") union_#{idx + 1}"
121
124
  end
122
125
  union_query_sql += ') subselect'
123
126
 
@@ -127,7 +130,8 @@ module Workhorse
127
130
  else
128
131
  select = Arel::SelectManager.new(ActiveRecord::Base, Arel.sql(union_query_sql))
129
132
  end
130
- select = order(select.project(Arel.star))
133
+ select = table.project(Arel.star).where(table[:id].in(select.project(:id)))
134
+ select = order(select)
131
135
 
132
136
  # Limit number of records
133
137
  select = agnostic_limit(select, limit)
@@ -145,12 +149,12 @@ module Workhorse
145
149
  return Workhorse::DbJob.find_by_sql(select.to_sql)
146
150
  end
147
151
 
148
- # Returns a fresh Arel select manager containing all waiting jobs, ordered
149
- # with {#order}.
152
+ # Returns a fresh Arel select manager containing the id of all waiting jobs,
153
+ # ordered with {#order}.
150
154
  #
151
155
  # @return [Arel::SelectManager] the select manager
152
- def valid_ordered_select
153
- select = table.project(table[Arel.star])
156
+ def valid_ordered_select_id
157
+ select = table.project(table[:id])
154
158
  select = select.where(table[:state].eq(:waiting))
155
159
  select = select.where(table[:perform_at].lteq(Time.now).or(table[:perform_at].eq(nil)))
156
160
  return order(select)
@@ -185,7 +189,7 @@ module Workhorse
185
189
  #
186
190
  # @return [Array] an array of unique queue names
187
191
  def valid_queues
188
- select = valid_ordered_select
192
+ select = valid_ordered_select_id
189
193
 
190
194
  # Restrict queues that are currently in progress
191
195
  bad_states = [Workhorse::DbJob::STATE_LOCKED, Workhorse::DbJob::STATE_STARTED]
@@ -150,6 +150,7 @@ class Workhorse::WorkerTest < WorkhorseTest
150
150
  def test_order_with_priorities
151
151
  Workhorse.enqueue BasicJob.new(some_param: 6, sleep_time: 0), priority: 4
152
152
  Workhorse.enqueue BasicJob.new(some_param: 4, sleep_time: 0), priority: 3
153
+ sleep 1
153
154
  Workhorse.enqueue BasicJob.new(some_param: 5, sleep_time: 0), priority: 3
154
155
  Workhorse.enqueue BasicJob.new(some_param: 3, sleep_time: 0), priority: 2
155
156
  Workhorse.enqueue BasicJob.new(some_param: 2, sleep_time: 0), priority: 1
data/workhorse.gemspec CHANGED
@@ -1,16 +1,16 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: workhorse 0.3.6 ruby lib
2
+ # stub: workhorse 0.3.7 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "workhorse".freeze
6
- s.version = "0.3.6"
6
+ s.version = "0.3.7"
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 = "2018-11-14"
11
+ s.date = "2018-12-17"
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/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/run_rails_op.rb".freeze, "lib/workhorse/performer.rb".freeze, "lib/workhorse/poller.rb".freeze, "lib/workhorse/pool.rb".freeze, "lib/workhorse/worker.rb".freeze, "test/lib/db_schema.rb".freeze, "test/lib/jobs.rb".freeze, "test/lib/test_helper.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
- s.rubygems_version = "2.7.6".freeze
13
+ s.rubygems_version = "2.7.7".freeze
14
14
  s.summary = "Multi-threaded job backend with database queuing for ruby.".freeze
15
15
  s.test_files = ["test/lib/db_schema.rb".freeze, "test/lib/jobs.rb".freeze, "test/lib/test_helper.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]
16
16
 
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: 0.3.6
4
+ version: 0.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sitrox
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-14 00:00:00.000000000 Z
11
+ date: 2018-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -212,7 +212,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
212
212
  version: '0'
213
213
  requirements: []
214
214
  rubyforge_project:
215
- rubygems_version: 2.7.6
215
+ rubygems_version: 2.7.7
216
216
  signing_key:
217
217
  specification_version: 4
218
218
  summary: Multi-threaded job backend with database queuing for ruby.