que 1.3.0 → 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -23,7 +23,7 @@ Que's secondary goal is performance. The worker process is multithreaded, so tha
23
23
 
24
24
  Compatibility:
25
25
 
26
- - MRI Ruby 2.2+
26
+ - MRI Ruby 2.2+, < 3 (for Ruby 3, Que 2+ is required)
27
27
  - PostgreSQL 9.5+
28
28
  - Rails 4.1+ (optional)
29
29
 
@@ -138,10 +138,9 @@ module Que
138
138
  opts.on(
139
139
  '--minimum-buffer-size [SIZE]',
140
140
  Integer,
141
- "Set minimum number of jobs to be locked and held in this " \
142
- "process awaiting a worker (default: 2)",
141
+ "Unused (deprecated)",
143
142
  ) do |s|
144
- options[:minimum_buffer_size] = s
143
+ warn "The --minimum-buffer-size SIZE option has been deprecated and will be removed in v2.0 (it's actually been unused since v1.0.0.beta4)"
145
144
  end
146
145
 
147
146
  opts.on(
@@ -236,7 +235,7 @@ OUTPUT
236
235
  <<~STARTUP
237
236
  Que #{Que::VERSION} started worker process with:
238
237
  Worker threads: #{locker.workers.length} (priorities: #{locker.workers.map { |w| w.priority || 'any' }.join(', ')})
239
- Buffer size: #{locker.job_buffer.minimum_size}-#{locker.job_buffer.maximum_size}
238
+ Buffer size: #{locker.job_buffer.maximum_size}
240
239
  Queues:
241
240
  #{locker.queues.map { |queue, interval| " - #{queue} (poll interval: #{interval}s)" }.join("\n")}
242
241
  Que waiting for jobs...
data/docs/README.md CHANGED
@@ -4,7 +4,7 @@ Docs Index
4
4
  - [Command Line Interface](#command-line-interface)
5
5
  * [worker-priorities and worker-count](#worker-priorities-and-worker-count)
6
6
  * [poll-interval](#poll-interval)
7
- * [minimum-buffer-size and maximum-buffer-size](#minimum-buffer-size-and-maximum-buffer-size)
7
+ * [maximum-buffer-size](#maximum-buffer-size)
8
8
  * [connection-url](#connection-url)
9
9
  * [wait-period](#wait-period)
10
10
  * [log-internals](#log-internals)
@@ -62,7 +62,6 @@ usage: que [options] [file/to/require] ...
62
62
  --connection-url [URL] Set a custom database url to connect to for locking purposes.
63
63
  --log-internals Log verbosely about Que's internal state. Only recommended for debugging issues
64
64
  --maximum-buffer-size [SIZE] Set maximum number of jobs to be locked and held in this process awaiting a worker (default: 8)
65
- --minimum-buffer-size [SIZE] Set minimum number of jobs to be locked and held in this process awaiting a worker (default: 2)
66
65
  --wait-period [PERIOD] Set maximum interval between checks of the in-memory job queue, in milliseconds (default: 50)
67
66
  ```
68
67
 
@@ -82,9 +81,9 @@ If you pass both worker-count and worker-priorities, the count will trim or pad
82
81
 
83
82
  This option sets the number of seconds the process will wait between polls of the job queue. Jobs that are ready to be worked immediately will be broadcast via the LISTEN/NOTIFY system, so polling is unnecessary for them - polling is only necessary for jobs that are scheduled in the future or which are being delayed due to errors. The default is 5 seconds.
84
83
 
85
- ### minimum-buffer-size and maximum-buffer-size
84
+ ### maximum-buffer-size
86
85
 
87
- These options set the size of the internal buffer that Que uses to hold jobs until they're ready for workers. The default minimum is 2 and the maximum is 8, meaning that the process won't buffer more than 8 jobs that aren't yet ready to be worked, and will only resort to polling if the buffer dips below 2. If you don't want jobs to be buffered at all, you can set both of these values to zero.
86
+ This option sets the size of the internal buffer that Que uses to hold jobs until they're ready for workers. The default maximum is 8, meaning that the process won't buffer more than 8 jobs that aren't yet ready to be worked. If you don't want jobs to be buffered at all, you can set this value to zero.
88
87
 
89
88
  ### connection-url
90
89
 
@@ -6,7 +6,7 @@
6
6
 
7
7
  module Que
8
8
  class JobBuffer
9
- attr_reader :maximum_size, :minimum_size, :priority_queues
9
+ attr_reader :maximum_size, :priority_queues
10
10
 
11
11
  # Since we use a mutex, which is not reentrant, we have to be a little
12
12
  # careful to not call a method that locks the mutex when we've already
@@ -17,20 +17,11 @@ module Que
17
17
 
18
18
  def initialize(
19
19
  maximum_size:,
20
- minimum_size:,
21
20
  priorities:
22
21
  )
23
22
  @maximum_size = Que.assert(Integer, maximum_size)
24
23
  Que.assert(maximum_size >= 0) { "maximum_size for a JobBuffer must be at least zero!" }
25
24
 
26
- @minimum_size = Que.assert(Integer, minimum_size)
27
- Que.assert(minimum_size >= 0) { "minimum_size for a JobBuffer must be at least zero!" }
28
-
29
- Que.assert(minimum_size <= maximum_size) do
30
- "minimum buffer size (#{minimum_size}) is " \
31
- "greater than the maximum buffer size (#{maximum_size})!"
32
- end
33
-
34
25
  @stop = false
35
26
  @array = []
36
27
  @mutex = Mutex.new
data/lib/que/locker.rb CHANGED
@@ -45,7 +45,6 @@ module Que
45
45
 
46
46
  DEFAULT_POLL_INTERVAL = 5.0
47
47
  DEFAULT_WAIT_PERIOD = 50
48
- DEFAULT_MINIMUM_BUFFER_SIZE = 2
49
48
  DEFAULT_MAXIMUM_BUFFER_SIZE = 8
50
49
  DEFAULT_WORKER_PRIORITIES = [10, 30, 50, nil, nil, nil].freeze
51
50
 
@@ -57,7 +56,6 @@ module Que
57
56
  poll_interval: DEFAULT_POLL_INTERVAL,
58
57
  wait_period: DEFAULT_WAIT_PERIOD,
59
58
  maximum_buffer_size: DEFAULT_MAXIMUM_BUFFER_SIZE,
60
- minimum_buffer_size: DEFAULT_MINIMUM_BUFFER_SIZE,
61
59
  worker_priorities: DEFAULT_WORKER_PRIORITIES,
62
60
  on_worker_start: nil
63
61
  )
@@ -77,7 +75,6 @@ module Que
77
75
  # ResultQueue to receive messages from workers.
78
76
  @job_buffer = JobBuffer.new(
79
77
  maximum_size: maximum_buffer_size,
80
- minimum_size: minimum_buffer_size,
81
78
  priorities: worker_priorities.uniq,
82
79
  )
83
80
 
@@ -93,7 +90,6 @@ module Que
93
90
  poll_interval: poll_interval,
94
91
  wait_period: wait_period,
95
92
  maximum_buffer_size: maximum_buffer_size,
96
- minimum_buffer_size: minimum_buffer_size,
97
93
  worker_priorities: worker_priorities,
98
94
  }
99
95
  end
data/lib/que/poller.rb CHANGED
@@ -146,8 +146,6 @@ module Que
146
146
 
147
147
  return unless should_poll?
148
148
 
149
- expected_count = priorities.inject(0){|s,(_,c)| s + c}
150
-
151
149
  jobs =
152
150
  connection.execute_prepared(
153
151
  :poll_jobs,
@@ -159,7 +157,7 @@ module Que
159
157
  )
160
158
 
161
159
  @last_polled_at = Time.now
162
- @last_poll_satisfied = expected_count == jobs.count
160
+ @last_poll_satisfied = poll_satisfied?(priorities, jobs)
163
161
 
164
162
  Que.internal_log :poller_polled, self do
165
163
  {
@@ -265,5 +263,12 @@ module Que
265
263
  SQL
266
264
  end
267
265
  end
266
+
267
+ private
268
+
269
+ def poll_satisfied?(priorities, jobs)
270
+ lowest_priority = priorities.keys.max
271
+ jobs.count >= priorities[lowest_priority]
272
+ end
268
273
  end
269
274
  end
data/lib/que/version.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Que
4
- VERSION = '1.3.0'
4
+ VERSION = '1.4.1'
5
5
 
6
6
  def self.job_schema_version
7
7
  1
data/lib/que.rb CHANGED
@@ -31,6 +31,8 @@ module Que
31
31
  require_relative 'que/utils/queue_management'
32
32
  require_relative 'que/utils/transactions'
33
33
 
34
+ require_relative 'que/version'
35
+
34
36
  require_relative 'que/connection'
35
37
  require_relative 'que/connection_pool'
36
38
  require_relative 'que/job_methods'
@@ -41,7 +43,6 @@ module Que
41
43
  require_relative 'que/migrations'
42
44
  require_relative 'que/poller'
43
45
  require_relative 'que/result_queue'
44
- require_relative 'que/version'
45
46
  require_relative 'que/worker'
46
47
 
47
48
  class << self
data/que.gemspec CHANGED
@@ -13,6 +13,8 @@ Gem::Specification.new do |spec|
13
13
  spec.homepage = 'https://github.com/que-rb/que'
14
14
  spec.license = 'MIT'
15
15
 
16
+ spec.required_ruby_version = '< 3'
17
+
16
18
  files_to_exclude = [
17
19
  /\A\.circleci/,
18
20
  /\AGemfile/,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: que
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Hanks
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-25 00:00:00.000000000 Z
11
+ date: 2022-07-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -100,16 +100,16 @@ require_paths:
100
100
  - lib
101
101
  required_ruby_version: !ruby/object:Gem::Requirement
102
102
  requirements:
103
- - - ">="
103
+ - - "<"
104
104
  - !ruby/object:Gem::Version
105
- version: '0'
105
+ version: '3'
106
106
  required_rubygems_version: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  requirements: []
112
- rubygems_version: 3.3.6
112
+ rubygems_version: 3.1.6
113
113
  signing_key:
114
114
  specification_version: 4
115
115
  summary: A PostgreSQL-based Job Queue