que-scheduler 4.4.0 → 4.6.0

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: aac67112308ae6e0840d46479cf890eb123f94c51ac9ac9a9a1b51900064cc96
4
- data.tar.gz: 1e268c0c918988a05e4bb5912ff47aee45b680ade2c3b422ea9dbf5c1bd0fd18
3
+ metadata.gz: a2e01f6eaa026842cf6f2041b3f979e571ca455427cdd70c8609d4f2a6c561a6
4
+ data.tar.gz: 3acb6027f4d8508f7fc7cbc2e27d55442783f4dcb3d855645bfb5e8db9054ad8
5
5
  SHA512:
6
- metadata.gz: 7ba7be6ea94dfa50387a329e39753ce1b17df38aa13e8c106c49c4eabaa3a249be8528d8fc6985201736a87a74ef318083f4f9661d6153191f484f06136f3ede
7
- data.tar.gz: eba73e89578334e55d4d39a253edf1d2822647eee62d733d52235184c8eaa9b36f64a7027fde5ed3c2a6ea2c73666a9ea6b82ed4ca62edbd5df1ed0bdeee6432
6
+ metadata.gz: e7c0eae15faf60069fc997a37d73c8521ab441e257ec18689d26b5cabc6fb7165a83207c54eee8890e4db43aac673263ef81072f9b7541bbbf12a45c427547ef
7
+ data.tar.gz: 2218a3e0b28e4d64ad7f7fc807ddff0761c46344b89e762e127dd49e833a5e2c11d6ed59726a8f0eba1b2fa10855b73415dc1a964819de5dcf1109be43d4349a
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  que-scheduler
2
2
  ================
3
3
 
4
- [![Gem Version](https://badge.fury.io/rb/que-scheduler.svg)](https://badge.fury.io/rb/que-scheduler)
4
+ [![Gem Version](https://img.shields.io/gem/v/que-scheduler?color=green)](https://img.shields.io/gem/v/que-scheduler?color=green)
5
5
  [![Coverage Status](https://coveralls.io/repos/github/hlascelles/que-scheduler/badge.svg?branch=master)](https://coveralls.io/github/hlascelles/que-scheduler?branch=master)
6
6
  [![Code Climate Maintainability](https://api.codeclimate.com/v1/badges/710d2fc5202f95d76e8a/maintainability)](https://codeclimate.com/github/hlascelles/que-scheduler/maintainability)
7
7
 
@@ -40,7 +40,8 @@ wish to generate the configuration dynamically, you can set it directly using an
40
40
 
41
41
  The file is a list of que job classes with arguments and a schedule frequency (in crontab
42
42
  syntax). The format is similar to the resque-scheduler format, though priorities must be supplied as
43
- integers, and job classes must be migrated from Resque to Que. Cron syntax can be anything
43
+ integers, and job classes must be migrated from Resque to Que.
44
+ ActiveJob classes configured to use `:que` adapter are also supported. Cron syntax can be anything
44
45
  understood by [fugit](https://github.com/floraison/fugit#fugitcron).
45
46
 
46
47
  It has one additional feature, `schedule_type: every_event`. This is set on a job that must be run for every
@@ -310,7 +311,8 @@ A full changelog can be found here: [CHANGELOG.md](https://github.com/hlascelles
310
311
 
311
312
  Your [postgres](https://www.postgresql.org/) database must be at least version 9.6.0.
312
313
 
313
- The latest version of que-scheduler supports Ruby 2.7 and above.
314
+ The latest version of que-scheduler supports Ruby 3.0 and above.
315
+ que-scheduler versions below 4.4.0 work with Ruby 2.7.
314
316
  que-scheduler versions below 4.2.3 work with Ruby 2.5 and Ruby 2.6.
315
317
 
316
318
  Using que 0.x with Rails 6 needs a patch to support it.
@@ -11,7 +11,7 @@ module Que
11
11
  INSERT INTO #{TABLE_NAME} (scheduler_job_id, executed_at)
12
12
  VALUES ($1::bigint, $2::timestamptz)
13
13
  RETURNING *
14
- }
14
+ }.freeze
15
15
  INSERT_AUDIT_ENQUEUED = %{
16
16
  INSERT INTO #{ENQUEUED_TABLE_NAME}
17
17
  (scheduler_job_id, job_class, queue, priority, args, job_id, run_at)
@@ -20,7 +20,7 @@ module Que
20
20
  $4::integer, $5::jsonb, $6::bigint, $7::timestamptz
21
21
  )
22
22
  RETURNING *
23
- }
23
+ }.freeze
24
24
 
25
25
  class << self
26
26
  def append(scheduler_job_id, executed_at, enqueued_jobs)
@@ -54,10 +54,8 @@ module Que
54
54
  validate_job_class_related(options)
55
55
  end
56
56
 
57
- private
58
-
59
57
  # rubocop:disable Style/GuardClause This reads better as a conditional
60
- def validate_fields_types(options)
58
+ private def validate_fields_types(options)
61
59
  unless queue.nil? || queue.is_a?(String)
62
60
  err_field(:queue, options, "queue must be a string")
63
61
  end
@@ -70,14 +68,14 @@ module Que
70
68
  end
71
69
  # rubocop:enable Style/GuardClause
72
70
 
73
- def validate_fields_presence(options)
71
+ private def validate_fields_presence(options)
74
72
  err_field(:name, options, "name must be present") if name.nil?
75
73
  err_field(:job_class, options, "job_class must be present") if job_class.nil?
76
74
  # An invalid cron is nil
77
75
  err_field(:cron, options, "cron must be present") if cron.nil?
78
76
  end
79
77
 
80
- def validate_job_class_related(options)
78
+ private def validate_job_class_related(options)
81
79
  # Only support known job engines
82
80
  unless Que::Scheduler::ToEnqueue.valid_job_class?(job_class)
83
81
  err_field(:job_class, options, "Job #{job_class} was not a supported job type")
@@ -104,14 +102,14 @@ module Que
104
102
  end
105
103
  end
106
104
 
107
- def err_field(field, options, reason = "")
105
+ private def err_field(field, options, reason = "")
108
106
  schedule = Que::Scheduler.configuration.schedule_location
109
107
  value = options[field]
110
108
  raise "Invalid #{field} '#{value}' for '#{name}' in que-scheduler schedule #{schedule}.\n" \
111
109
  "#{reason}"
112
110
  end
113
111
 
114
- def generate_to_enqueue_list(missed_times)
112
+ private def generate_to_enqueue_list(missed_times)
115
113
  return [] if missed_times.empty?
116
114
 
117
115
  options = to_h.slice(:args, :queue, :priority, :job_class).compact
@@ -8,7 +8,7 @@ module Que
8
8
  SELECT description FROM pg_class
9
9
  LEFT JOIN pg_description ON pg_description.objoid = pg_class.oid
10
10
  WHERE relname = '#{AUDIT_TABLE_NAME}'
11
- )
11
+ ).freeze
12
12
  MAX_VERSION = Dir.glob("#{__dir__}/migrations/*").map { |d| File.basename(d) }.map(&:to_i).max
13
13
 
14
14
  class << self
@@ -48,21 +48,19 @@ module Que
48
48
  Que::Scheduler::VersionSupport.enqueue_a_job(Que::Scheduler::SchedulerJob)
49
49
  end
50
50
 
51
- private
52
-
53
- def migrate_up(current, version)
51
+ private def migrate_up(current, version)
54
52
  if current.zero? # Version 1 does not use SQL
55
53
  Que::Scheduler::VersionSupport.enqueue_a_job(Que::Scheduler::SchedulerJob)
56
54
  end
57
55
  execute_step((current += 1), :up) until current == version
58
56
  end
59
57
 
60
- def migrate_down(current, version)
58
+ private def migrate_down(current, version)
61
59
  current += 1
62
60
  execute_step((current -= 1), :down) until current == version + 1
63
61
  end
64
62
 
65
- def execute_step(number, direction)
63
+ private def execute_step(number, direction)
66
64
  sql = File.read("#{__dir__}/migrations/#{number}/#{direction}.sql")
67
65
  Que::Scheduler::VersionSupport.execute(sql)
68
66
  return unless audit_table_exists?
@@ -38,16 +38,14 @@ module Que
38
38
  end
39
39
 
40
40
  def enqueue_required_jobs(calculator_result, logs)
41
- calculator_result.missed_jobs.map do |to_enqueue|
41
+ calculator_result.missed_jobs.filter_map do |to_enqueue|
42
42
  to_enqueue.enqueue.tap do |enqueued_job|
43
43
  check_enqueued_job(to_enqueue, enqueued_job, logs)
44
44
  end
45
- end.compact
45
+ end
46
46
  end
47
47
 
48
- private
49
-
50
- def check_enqueued_job(to_enqueue, enqueued_job, logs)
48
+ private def check_enqueued_job(to_enqueue, enqueued_job, logs)
51
49
  logs << if enqueued_job.present?
52
50
  "que-scheduler enqueueing #{enqueued_job.job_class} " \
53
51
  "#{enqueued_job.job_id} with args: #{enqueued_job.args}"
@@ -58,7 +56,8 @@ module Que
58
56
  end
59
57
  end
60
58
 
61
- def enqueue_self_again(scheduler_job_args, last_full_execution, job_dictionary, enqueued_jobs)
59
+ private def enqueue_self_again(scheduler_job_args, last_full_execution, job_dictionary,
60
+ enqueued_jobs)
62
61
  # Log last run...
63
62
  job_id = VersionSupport.job_attributes(self).fetch(:job_id)
64
63
  Audit.append(job_id, scheduler_job_args.as_time, enqueued_jobs)
@@ -10,9 +10,7 @@ module Que
10
10
  assert_db_migrated
11
11
  end
12
12
 
13
- private
14
-
15
- def assert_db_migrated
13
+ private def assert_db_migrated
16
14
  db_version = Que::Scheduler::Migrations.db_version
17
15
  return if db_version == Que::Scheduler::Migrations::MAX_VERSION
18
16
 
@@ -23,7 +23,7 @@ module Que
23
23
  end
24
24
 
25
25
  def active_job_defined?
26
- Object.const_defined?("ActiveJob")
26
+ Object.const_defined?(:ActiveJob)
27
27
  end
28
28
 
29
29
  def active_job_version
@@ -39,16 +39,14 @@ module Que
39
39
  Gem::Version.create("6.0.3")
40
40
  end
41
41
 
42
- private
43
-
44
- def type_from_job_class(job_class)
42
+ private def type_from_job_class(job_class)
45
43
  types.each do |type, implementation|
46
44
  return implementation if job_class < type
47
45
  end
48
46
  nil
49
47
  end
50
48
 
51
- def types
49
+ private def types
52
50
  @types ||=
53
51
  begin
54
52
  hash = {
@@ -1,5 +1,5 @@
1
1
  module Que
2
2
  module Scheduler
3
- VERSION = "4.4.0".freeze
3
+ VERSION = "4.6.0".freeze
4
4
  end
5
5
  end
@@ -15,7 +15,7 @@ module Que
15
15
  # the top of all jobs it enqueues.
16
16
  def set_priority(context, priority)
17
17
  if zero_major?
18
- context.instance_variable_set("@priority", priority)
18
+ context.instance_variable_set(:@priority, priority)
19
19
  else
20
20
  context.priority = priority
21
21
  end
@@ -24,7 +24,7 @@ module Que
24
24
  # Ensure the job runs at least once an hour when it is backing off due to errors
25
25
  def apply_retry_semantics(context)
26
26
  if zero_major?
27
- context.instance_variable_set("@retry_interval", RETRY_PROC)
27
+ context.instance_variable_set(:@retry_interval, RETRY_PROC)
28
28
  else
29
29
  context.maximum_retry_count = 1 << 128 # Heat death of universe
30
30
  context.retry_interval = RETRY_PROC
@@ -92,17 +92,15 @@ module Que
92
92
  @que_version ||= que_version_object.to_s
93
93
  end
94
94
 
95
- private
96
-
97
- def supports_job_options_keyword?
95
+ private def supports_job_options_keyword?
98
96
  @supports_job_options_keyword ||= que_version_object >= Gem::Version.new("1.2.0")
99
97
  end
100
98
 
101
- def que_version_object
99
+ private def que_version_object
102
100
  @que_version_object ||= Gem.loaded_specs["que"].version
103
101
  end
104
102
 
105
- def normalise_array_of_hashes(array)
103
+ private def normalise_array_of_hashes(array)
106
104
  array.map { |row| row.to_h.transform_keys(&:to_sym) }
107
105
  end
108
106
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: que-scheduler
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.4.0
4
+ version: 4.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Harry Lascelles
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-24 00:00:00.000000000 Z
11
+ date: 2024-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '5.0'
19
+ version: '6.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '5.0'
26
+ version: '6.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: fugit
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -175,7 +175,7 @@ dependencies:
175
175
  - !ruby/object:Gem::Version
176
176
  version: '0'
177
177
  - !ruby/object:Gem::Dependency
178
- name: fasterer
178
+ name: dememoize
179
179
  requirement: !ruby/object:Gem::Requirement
180
180
  requirements:
181
181
  - - ">="
@@ -189,7 +189,7 @@ dependencies:
189
189
  - !ruby/object:Gem::Version
190
190
  version: '0'
191
191
  - !ruby/object:Gem::Dependency
192
- name: pg
192
+ name: fasterer
193
193
  requirement: !ruby/object:Gem::Requirement
194
194
  requirements:
195
195
  - - ">="
@@ -202,6 +202,20 @@ dependencies:
202
202
  - - ">="
203
203
  - !ruby/object:Gem::Version
204
204
  version: '0'
205
+ - !ruby/object:Gem::Dependency
206
+ name: pg
207
+ requirement: !ruby/object:Gem::Requirement
208
+ requirements:
209
+ - - ">="
210
+ - !ruby/object:Gem::Version
211
+ version: '1.0'
212
+ type: :development
213
+ prerelease: false
214
+ version_requirements: !ruby/object:Gem::Requirement
215
+ requirements:
216
+ - - ">="
217
+ - !ruby/object:Gem::Version
218
+ version: '1.0'
205
219
  - !ruby/object:Gem::Dependency
206
220
  name: pry-byebug
207
221
  requirement: !ruby/object:Gem::Requirement
@@ -286,6 +300,20 @@ dependencies:
286
300
  - - ">="
287
301
  - !ruby/object:Gem::Version
288
302
  version: '0'
303
+ - !ruby/object:Gem::Dependency
304
+ name: rubocop-performance
305
+ requirement: !ruby/object:Gem::Requirement
306
+ requirements:
307
+ - - ">="
308
+ - !ruby/object:Gem::Version
309
+ version: '0'
310
+ type: :development
311
+ prerelease: false
312
+ version_requirements: !ruby/object:Gem::Requirement
313
+ requirements:
314
+ - - ">="
315
+ - !ruby/object:Gem::Version
316
+ version: '0'
289
317
  - !ruby/object:Gem::Dependency
290
318
  name: rubocop-rspec
291
319
  requirement: !ruby/object:Gem::Requirement
@@ -391,7 +419,7 @@ metadata:
391
419
  source_code_uri: https://github.com/hlascelles/que-scheduler/
392
420
  bug_tracker_uri: https://github.com/hlascelles/que-scheduler/issues
393
421
  rubygems_mfa_required: 'true'
394
- post_install_message:
422
+ post_install_message:
395
423
  rdoc_options: []
396
424
  require_paths:
397
425
  - lib
@@ -399,15 +427,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
399
427
  requirements:
400
428
  - - ">="
401
429
  - !ruby/object:Gem::Version
402
- version: '2.7'
430
+ version: '3.0'
403
431
  required_rubygems_version: !ruby/object:Gem::Requirement
404
432
  requirements:
405
433
  - - ">="
406
434
  - !ruby/object:Gem::Version
407
435
  version: '0'
408
436
  requirements: []
409
- rubygems_version: 3.1.6
410
- signing_key:
437
+ rubygems_version: 3.3.26
438
+ signing_key:
411
439
  specification_version: 4
412
440
  summary: A cron scheduler for Que
413
441
  test_files: []