advanced-sneakers-activejob 0.3.6 → 0.4.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7828be1674a92df4c43f0e86df282461e158438252ea16439d26f3ffc3bf1a22
|
4
|
+
data.tar.gz: 1e0248e9dd8b8af0b3c5b5da1294bc970f93f501bfb8185c19c1da486d78514f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd60af5cc86febf88ec62c11dbe5b90b5528f96d1b7b4a357cec61e01260e3b587a4e3e69b171508866685827468c1084a294baa3e5a2ba8c7cbf35a8cae20f0
|
7
|
+
data.tar.gz: 546258b0a88d0a105ac120dcb90c68c3608f8a4123e5ad556881f5fed331bb18a68ea074801f286d5c3d64ecc2814a75fd1fc0ad5866708908a230cf09e3e5b6
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -4,7 +4,13 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
6
6
|
|
7
|
-
## [Unreleased](https://github.com/veeqo/advanced-sneakers-activejob/compare/v0.
|
7
|
+
## [Unreleased](https://github.com/veeqo/advanced-sneakers-activejob/compare/v0.4.0...HEAD)
|
8
|
+
|
9
|
+
|
10
|
+
## [0.4.0](https://github.com/veeqo/advanced-sneakers-activejob/compare/v0.3.6...v0.4.0) - 2020-11-17
|
11
|
+
|
12
|
+
### Added
|
13
|
+
- [#15](https://github.com/veeqo/advanced-sneakers-activejob/pull/15) Add ability to set AMQP message options per job
|
8
14
|
|
9
15
|
|
10
16
|
## [0.3.6](https://github.com/veeqo/advanced-sneakers-activejob/compare/v0.3.5...v0.3.6) - 2020-09-18
|
data/README.md
CHANGED
@@ -66,7 +66,7 @@ Take into accout that **this process is asynchronous**. It means that in case of
|
|
66
66
|
|
67
67
|
## Custom message options
|
68
68
|
|
69
|
-
Advanced sneakers adapter allows to set custom message options (e.g. [routing keys](https://www.rabbitmq.com/tutorials/tutorial-four-ruby.html)).
|
69
|
+
Advanced sneakers adapter allows to set [custom message options](http://reference.rubybunny.info/Bunny/Exchange.html#publish-instance_method) (e.g. [routing keys](https://www.rabbitmq.com/tutorials/tutorial-four-ruby.html)) on class-level.
|
70
70
|
|
71
71
|
```ruby
|
72
72
|
class MyJob < ActiveJob::Base
|
@@ -96,6 +96,14 @@ class MyJob < ActiveJob::Base
|
|
96
96
|
end
|
97
97
|
```
|
98
98
|
|
99
|
+
And also supports custom message options per job
|
100
|
+
```ruby
|
101
|
+
MyJob.set(priority: 1, headers: { 'foo' => 'bar' }).perform_later('baz')
|
102
|
+
```
|
103
|
+
|
104
|
+
Read more about message properties:
|
105
|
+
- https://www.rabbitmq.com/publishers.html#message-properties
|
106
|
+
- http://reference.rubybunny.info/Bunny/Exchange.html#publish-instance_method
|
99
107
|
|
100
108
|
Take into accout that **custom message options are used for publishing only**.
|
101
109
|
|
@@ -47,11 +47,7 @@ module ActiveJob
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def build_publish_params(job)
|
50
|
-
params = job
|
51
|
-
|
52
|
-
params.each do |key, value|
|
53
|
-
params[key] = value.call(job) if value.respond_to?(:call)
|
54
|
-
end
|
50
|
+
params = merged_publish_options(job)
|
55
51
|
|
56
52
|
unless params.key?(:routing_key)
|
57
53
|
params[:routing_key] = job.queue_name.respond_to?(:call) ? job.queue_name.call : job.queue_name
|
@@ -59,6 +55,18 @@ module ActiveJob
|
|
59
55
|
|
60
56
|
params
|
61
57
|
end
|
58
|
+
|
59
|
+
def merged_publish_options(job)
|
60
|
+
publish_options = job.class.publish_options.deep_dup || {}
|
61
|
+
|
62
|
+
publish_options.each do |key, value|
|
63
|
+
publish_options[key] = value.call(job) if value.respond_to?(:call)
|
64
|
+
end
|
65
|
+
|
66
|
+
publish_options.deep_merge!(job.publish_options) if job.publish_options.present?
|
67
|
+
|
68
|
+
publish_options
|
69
|
+
end
|
62
70
|
end
|
63
71
|
|
64
72
|
delegate :enqueue, :enqueue_at, to: :'ActiveJob::QueueAdapters::AdvancedSneakersAdapter' # compatibility with Rails 5+
|
@@ -6,7 +6,7 @@ module AdvancedSneakersActiveJob
|
|
6
6
|
|
7
7
|
included do
|
8
8
|
# AMQP message contains metadata which might be helpful for consumer (e.g. job.delivery_info.routing_key)
|
9
|
-
attr_accessor :delivery_info, :headers
|
9
|
+
attr_accessor :delivery_info, :headers, :publish_options
|
10
10
|
|
11
11
|
class_attribute :publish_options, instance_accessor: false
|
12
12
|
end
|
@@ -25,5 +25,13 @@ module AdvancedSneakersActiveJob
|
|
25
25
|
self.publish_options = options.symbolize_keys
|
26
26
|
end
|
27
27
|
end
|
28
|
+
|
29
|
+
def enqueue(options = {})
|
30
|
+
# Since ActiveJob v5 :priority option is supported natively https://github.com/rails/rails/pull/19425
|
31
|
+
# publish_options holds its own :priority to "backport" priority feature to ActiveJob v4
|
32
|
+
self.publish_options = options.except(:wait, :wait_until, :queue)
|
33
|
+
|
34
|
+
super
|
35
|
+
end
|
28
36
|
end
|
29
37
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: advanced-sneakers-activejob
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rustam Sharshenov
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-
|
12
|
+
date: 2020-11-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activejob
|
@@ -184,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
184
184
|
- !ruby/object:Gem::Version
|
185
185
|
version: '0'
|
186
186
|
requirements: []
|
187
|
-
rubygems_version: 3.1.
|
187
|
+
rubygems_version: 3.1.2
|
188
188
|
signing_key:
|
189
189
|
specification_version: 4
|
190
190
|
summary: Advanced Sneakers adapter for ActiveJob
|