workhorse 0.3.8 → 0.3.9

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: aa9dc25d7a2e9ec126e65a928ad34ebe2582223372524ca80b2b6ad92eb191e7
4
- data.tar.gz: 85074d1dd6e73dd83028f98629bd5c83637cf08c230815c0b7cce390c30acf44
3
+ metadata.gz: 4bcaee406798a7da933fd0a48c7e556447a589a6be42f73d259902ae3a69b339
4
+ data.tar.gz: 2201639a37267a0980b873d0398222fbd0da0ac0a672244180a37b7e0b5265aa
5
5
  SHA512:
6
- metadata.gz: 39b04d08e72d36e17261947dec59a19ca4c62be283856606e37a201a94b923007fd80b885dab1ef267d6a13feea9620cec6609761d15fdb19aeebc8b4bb206b7
7
- data.tar.gz: 2f5e84a4272556eaaa94c4893b7552cd730f830b28644869b0360e74e6dbc30c8cacd8c113728d092190f91c58b9e8a9455a5513e7aff23518191ec5a1e2f7fa
6
+ metadata.gz: 4f7813c2d5945df4a9a4757b2dd3ac2f270da19888b5d47cff50a3e5321bef65ded194d0775b30719754b20018c4050dc46ee0f602f445871661edf400a4afda
7
+ data.tar.gz: db1da7961291a3eefd8c066fe9b36e8e0d4ce0fcb673968229b364b79e5fbe37e06574f506f1a1024487dbb1d73d667b92a14726d9adcce8791962a850505d8a
data/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.3.9 – 2019-03-09
6
+
7
+ * Fixed error where jobs without queue were blocked by a locked/running job
8
+ that also was without a queue
9
+
5
10
  ## 0.3.8 – 2018-12-19
6
11
 
7
12
  * Fixed incompatibility in the combination of Oracle DB and Arel < 7.0.0
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2018 Sitrox
3
+ Copyright (c) 2019 Sitrox
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -267,4 +267,4 @@ Please consult the [FAQ](FAQ.md).
267
267
 
268
268
  ## Copyright
269
269
 
270
- Copyright © 2018 Sitrox. See `LICENSE` for further details.
270
+ Copyright © 2019 Sitrox. See `LICENSE` for further details.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.8
1
+ 0.3.9
@@ -187,21 +187,23 @@ module Workhorse
187
187
  # Returns an Array of queue names for which a job may be posted
188
188
  #
189
189
  # This is done in multiple steps. First, all queues with jobs that are in
190
- # progress are removed. Second, restrict to only queues for which we may
191
- # post jobs. Third, extract the queue names of the remaining queues and
192
- # return them in an Array.
190
+ # progress are removed, with the exception of the nil queue. Second, we
191
+ # restrict to only queues for which we may post jobs. Third, we extract the
192
+ # queue names of the remaining queues and return them in an Array.
193
193
  #
194
194
  # @return [Array] an array of unique queue names
195
195
  def valid_queues
196
196
  select = valid_ordered_select_id
197
197
 
198
- # Restrict queues that are currently in progress
198
+ # Restrict queues that are currently in progress, except for the nil
199
+ # queue, where jobs may run in parallel
199
200
  bad_states = [Workhorse::DbJob::STATE_LOCKED, Workhorse::DbJob::STATE_STARTED]
200
- bad_queries_select = table.project(table[:queue])
201
- .where(table[:state].in(bad_states))
201
+ bad_queues_select = table.project(table[:queue])
202
+ .where(table[:queue].not_eq(nil))
203
+ .where(table[:state].in(bad_states))
202
204
  # .distinct is not chainable in older Arel versions
203
- bad_queries_select.distinct
204
- select = select.where(table[:queue].not_in(bad_queries_select))
205
+ bad_queues_select.distinct
206
+ select = select.where(table[:queue].not_in(bad_queues_select))
205
207
 
206
208
  # Restrict queues to valid ones as indicated by the options given to the
207
209
  # worker
@@ -47,4 +47,24 @@ class Workhorse::PollerTest < WorkhorseTest
47
47
 
48
48
  assert_equal %w[q1 q2], w.poller.send(:valid_queues)
49
49
  end
50
+
51
+ def test_no_queues
52
+ w = Workhorse::Worker.new(polling_interval: 60)
53
+ assert_equal [], w.poller.send(:valid_queues)
54
+ end
55
+
56
+ def test_nil_queues
57
+ w = Workhorse::Worker.new(pool_size: 2, polling_interval: 60)
58
+
59
+ 3.times do
60
+ Workhorse.enqueue BasicJob.new(sleep_time: 2)
61
+ end
62
+ jobs = Workhorse::DbJob.all
63
+
64
+ assert_equal [nil], w.poller.send(:valid_queues)
65
+
66
+ jobs[0].mark_locked!(42)
67
+
68
+ assert_equal [nil], w.poller.send(:valid_queues)
69
+ end
50
70
  end
@@ -162,10 +162,10 @@ class Workhorse::WorkerTest < WorkhorseTest
162
162
  end
163
163
 
164
164
  def test_polling_interval
165
- w = Workhorse::Worker.new(polling_interval: 1)
166
- w = Workhorse::Worker.new(polling_interval: 1.1)
165
+ assert Workhorse::Worker.new(polling_interval: 1)
166
+ assert Workhorse::Worker.new(polling_interval: 1.1)
167
167
  err = assert_raises do
168
- w = Workhorse::Worker.new(polling_interval: 1.12)
168
+ Workhorse::Worker.new(polling_interval: 1.12)
169
169
  end
170
170
  assert_equal 'Polling interval must be a multiple of 0.1.', err.message
171
171
  end
data/workhorse.gemspec CHANGED
@@ -1,16 +1,16 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: workhorse 0.3.8 ruby lib
2
+ # stub: workhorse 0.3.9 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "workhorse".freeze
6
- s.version = "0.3.8"
6
+ s.version = "0.3.9"
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-12-19"
11
+ s.date = "2019-04-09"
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.7".freeze
13
+ s.rubygems_version = "3.0.3".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.8
4
+ version: 0.3.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sitrox
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-19 00:00:00.000000000 Z
11
+ date: 2019-04-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -211,8 +211,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
211
211
  - !ruby/object:Gem::Version
212
212
  version: '0'
213
213
  requirements: []
214
- rubyforge_project:
215
- rubygems_version: 2.7.7
214
+ rubygems_version: 3.0.3
216
215
  signing_key:
217
216
  specification_version: 4
218
217
  summary: Multi-threaded job backend with database queuing for ruby.