que 1.1.0 → 1.2.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: 2be51744809f55950825aa7bbb6c3e4d7d4d0927a439dfdf2c1f3658f53cfc84
4
- data.tar.gz: f1c7b10f27e57fd11288f50789cef31574e11a333733dfbae93e870841dabf28
3
+ metadata.gz: 967eded27a81df945b65911275dcdc7925113727bfd06fbc42cb780a3bfb6fcf
4
+ data.tar.gz: 87607b262263b13623b4b09822a478c02179e57cfa503f253e3e678ac8b1490a
5
5
  SHA512:
6
- metadata.gz: 93688d24737b750e85c1769bebc6d1344264a8b9757c855150c1dd022104a6400e205442db443bf12c8623325a8178b5379ff647faecd47ada873ead78d5ce7e
7
- data.tar.gz: 7fc7c9e34adb2f779f947c0d8326da32c40ba47c7fe4501e343fc177d3115275a25e28b8b407aa62a3ce7d095760f4f392fb9f501892918fc5d2dc3802871f93
6
+ metadata.gz: 3d8242fe07445a6f4658f322dd1a7cdb8918c8a56c2bfad2db49c58695b4ebae183e6a56159abc4ff74316006e7d95459ab6cfd8a4c98410eea50a2e4fb52509
7
+ data.tar.gz: 24fdf63cab7ff6e8a2ffa6ed598718d3c2ae2cbc6ef61de22ab6f1541b0cc23bab980fe5d10bbcb54823b2a529cd1cdc9d57437db3905e802bec92a04ea3ed94
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ### 1.2.0 (2022-02-23)
2
+
3
+ - **Deprecated**
4
+ + Providing job options as top level keyword arguments to Job.enqueue is now deprecated. Support will be dropped in `2.0`. Job options should be nested under the `job_options` keyword arg instead. See [#336](https://github.com/que-rb/que/pull/336)
5
+
1
6
  ### 1.1.0 (2022-02-21)
2
7
 
3
8
  - **Features**:
data/lib/que/job.rb CHANGED
@@ -57,22 +57,18 @@ module Que
57
57
 
58
58
  def enqueue(
59
59
  *args,
60
- queue: nil,
61
- priority: nil,
62
- run_at: nil,
63
- job_class: nil,
64
- tags: nil,
60
+ job_options: {},
65
61
  **arg_opts
66
62
  )
67
-
63
+ arg_opts, job_options = _extract_job_options(arg_opts, job_options.dup)
68
64
  args << arg_opts if arg_opts.any?
69
65
 
70
- if tags
71
- if tags.length > MAXIMUM_TAGS_COUNT
72
- raise Que::Error, "Can't enqueue a job with more than #{MAXIMUM_TAGS_COUNT} tags! (passed #{tags.length})"
66
+ if job_options[:tags]
67
+ if job_options[:tags].length > MAXIMUM_TAGS_COUNT
68
+ raise Que::Error, "Can't enqueue a job with more than #{MAXIMUM_TAGS_COUNT} tags! (passed #{job_options[:tags].length})"
73
69
  end
74
70
 
75
- tags.each do |tag|
71
+ job_options[:tags].each do |tag|
76
72
  if tag.length > MAXIMUM_TAG_LENGTH
77
73
  raise Que::Error, "Can't enqueue a job with a tag longer than 100 characters! (\"#{tag}\")"
78
74
  end
@@ -80,13 +76,13 @@ module Que
80
76
  end
81
77
 
82
78
  attrs = {
83
- queue: queue || resolve_que_setting(:queue) || Que.default_queue,
84
- priority: priority || resolve_que_setting(:priority),
85
- run_at: run_at || resolve_que_setting(:run_at),
79
+ queue: job_options[:queue] || resolve_que_setting(:queue) || Que.default_queue,
80
+ priority: job_options[:priority] || resolve_que_setting(:priority),
81
+ run_at: job_options[:run_at] || resolve_que_setting(:run_at),
86
82
  args: Que.serialize_json(args),
87
- data: tags ? Que.serialize_json(tags: tags) : "{}",
83
+ data: job_options[:tags] ? Que.serialize_json(tags: job_options[:tags]) : "{}",
88
84
  job_class: \
89
- job_class || name ||
85
+ job_options[:job_class] || name ||
90
86
  raise(Error, "Can't enqueue an anonymous subclass of Que::Job"),
91
87
  }
92
88
 
@@ -139,6 +135,27 @@ module Que
139
135
  end
140
136
  end
141
137
  end
138
+
139
+ def _extract_job_options(arg_opts, job_options)
140
+ deprecated_job_option_names = []
141
+
142
+ %i[queue priority run_at job_class tags].each do |option_name|
143
+ next unless arg_opts.key?(option_name) && job_options[option_name].nil?
144
+
145
+ job_options[option_name] = arg_opts.delete(option_name)
146
+ deprecated_job_option_names << option_name
147
+ end
148
+
149
+ _log_job_options_deprecation(deprecated_job_option_names)
150
+
151
+ [arg_opts, job_options]
152
+ end
153
+
154
+ def _log_job_options_deprecation(deprecated_job_option_names)
155
+ return unless deprecated_job_option_names.any?
156
+
157
+ warn "Passing job options like (#{deprecated_job_option_names.join(', ')}) to `JobClass.enqueue` as top level keyword args has been deprecated and will be removed in version 2.0. Please wrap job options in an explicit `job_options` keyword arg instead."
158
+ end
142
159
  end
143
160
 
144
161
  # Set up some defaults.
data/lib/que/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Que
4
- VERSION = '1.1.0'
4
+ VERSION = '1.2.0'
5
5
  end
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.1.0
4
+ version: 1.2.0
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-21 00:00:00.000000000 Z
11
+ date: 2022-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -106,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
106
  - !ruby/object:Gem::Version
107
107
  version: '0'
108
108
  requirements: []
109
- rubygems_version: 3.3.6
109
+ rubygems_version: 3.1.6
110
110
  signing_key:
111
111
  specification_version: 4
112
112
  summary: A PostgreSQL-based Job Queue