advanced-sneakers-activejob 0.3.2 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +19 -4
- data/.travis.yml +13 -9
- data/Appraisals +13 -0
- data/CHANGELOG.md +70 -27
- data/Gemfile +1 -5
- data/README.md +21 -2
- data/advanced-sneakers-activejob.gemspec +2 -3
- data/gemfiles/.bundle/config +3 -0
- data/gemfiles/activejob_4.2.x.gemfile +7 -0
- data/gemfiles/activejob_5.2.x.gemfile +7 -0
- data/gemfiles/activejob_6.0.x.gemfile +7 -0
- data/lib/active_job/queue_adapters/advanced_sneakers_adapter.rb +13 -5
- data/lib/advanced_sneakers_activejob.rb +10 -2
- data/lib/advanced_sneakers_activejob/active_job_patch.rb +9 -1
- data/lib/advanced_sneakers_activejob/railtie.rb +0 -12
- data/lib/advanced_sneakers_activejob/support/locate_workers_by_queues.rb +53 -0
- data/lib/advanced_sneakers_activejob/tasks.rb +13 -1
- data/lib/advanced_sneakers_activejob/version.rb +1 -1
- metadata +27 -35
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/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,8 +1,23 @@
|
|
1
|
+
AllCops:
|
2
|
+
NewCops: enable
|
3
|
+
Exclude:
|
4
|
+
- gemfiles/**/*
|
5
|
+
|
1
6
|
Layout/LineLength:
|
2
7
|
Max: 140
|
3
8
|
Exclude:
|
4
9
|
- spec/**/*
|
5
10
|
|
11
|
+
Lint/SuppressedException:
|
12
|
+
Exclude:
|
13
|
+
- spec/**/*
|
14
|
+
|
15
|
+
Lint/ConstantDefinitionInBlock:
|
16
|
+
Enabled: false
|
17
|
+
|
18
|
+
Gemspec/RequiredRubyVersion:
|
19
|
+
Enabled: false
|
20
|
+
|
6
21
|
Metrics/ClassLength:
|
7
22
|
Enabled: false
|
8
23
|
|
@@ -11,6 +26,10 @@ Metrics/BlockLength:
|
|
11
26
|
- advanced-sneakers-activejob.gemspec
|
12
27
|
- spec/**/*
|
13
28
|
|
29
|
+
Metrics/CyclomaticComplexity:
|
30
|
+
Exclude:
|
31
|
+
- spec/support/log_helpers.rb
|
32
|
+
|
14
33
|
Metrics/MethodLength:
|
15
34
|
Exclude:
|
16
35
|
- spec/**/*
|
@@ -27,9 +46,5 @@ Metrics/AbcSize:
|
|
27
46
|
Exclude:
|
28
47
|
- spec/**/*
|
29
48
|
|
30
|
-
Lint/SuppressedException:
|
31
|
-
Exclude:
|
32
|
-
- spec/**/*
|
33
|
-
|
34
49
|
Style/Documentation:
|
35
50
|
Enabled: false
|
data/.travis.yml
CHANGED
@@ -2,20 +2,24 @@
|
|
2
2
|
dist: xenial
|
3
3
|
language: ruby
|
4
4
|
cache: bundler
|
5
|
+
|
5
6
|
rvm:
|
6
7
|
- 2.5.8
|
7
8
|
- 2.6.6
|
8
9
|
- 2.7.1
|
9
|
-
|
10
|
-
|
11
|
-
-
|
12
|
-
-
|
13
|
-
|
10
|
+
|
11
|
+
gemfile:
|
12
|
+
- gemfiles/activejob_4.2.x.gemfile
|
13
|
+
- gemfiles/activejob_5.2.x.gemfile
|
14
|
+
- gemfiles/activejob_6.0.x.gemfile
|
15
|
+
|
16
|
+
matrix:
|
14
17
|
exclude:
|
15
18
|
- rvm: 2.7.1
|
16
|
-
|
19
|
+
gemfile: gemfiles/activejob_4.2.x.gemfile
|
20
|
+
|
21
|
+
before_install: 'gem install bundler -v "$(ruby -e "puts RUBY_VERSION.to_f >= 2.7 ? \">= 2.0\" : \"< 2\"")"'
|
22
|
+
|
23
|
+
before_script: .ci/install_rabbitmq
|
17
24
|
|
18
|
-
before_install: gem install bundler -v 1.17.3
|
19
|
-
before_script:
|
20
|
-
- ".ci/install_rabbitmq"
|
21
25
|
bundler_args: --jobs 3 --retry 3
|
data/Appraisals
ADDED
data/CHANGELOG.md
CHANGED
@@ -1,48 +1,91 @@
|
|
1
|
-
|
1
|
+
# Changelog
|
2
2
|
|
3
|
-
|
3
|
+
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
|
-
|
8
|
-
WORKERS=MyConsumer rake sneakers:run
|
9
|
-
```
|
7
|
+
## [Unreleased](https://github.com/veeqo/advanced-sneakers-activejob/compare/v0.4.0...HEAD)
|
10
8
|
|
11
|
-
Now it works for ActiveJob queues consumers as well:
|
12
9
|
|
13
|
-
|
14
|
-
WORKERS=AdvancedSneakersActiveJob::MailersConsumer rake sneakers:run
|
15
|
-
```
|
10
|
+
## [0.4.0](https://github.com/veeqo/advanced-sneakers-activejob/compare/v0.3.6...v0.4.0) - 2020-11-17
|
16
11
|
|
17
|
-
|
12
|
+
### Added
|
13
|
+
- [#15](https://github.com/veeqo/advanced-sneakers-activejob/pull/15) Add ability to set AMQP message options per job
|
18
14
|
|
19
|
-
### [Restore Sneakers::Worker::Classes methods](https://github.com/veeqo/advanced-sneakers-activejob/pull/6)
|
20
15
|
|
21
|
-
##
|
16
|
+
## [0.3.6](https://github.com/veeqo/advanced-sneakers-activejob/compare/v0.3.5...v0.3.6) - 2020-09-18
|
22
17
|
|
23
|
-
|
18
|
+
### Changed
|
19
|
+
- [#12](https://github.com/veeqo/advanced-sneakers-activejob/pull/12) Refactor changelog to comply with Keep a Changelog
|
20
|
+
- [#13](https://github.com/veeqo/advanced-sneakers-activejob/pull/13) Use appraisals for Travis matrix
|
24
21
|
|
25
|
-
###
|
22
|
+
### Fixed
|
23
|
+
- [#14](https://github.com/veeqo/advanced-sneakers-activejob/pull/14) Fix deprecation warnings of ruby 2.7
|
26
24
|
|
27
|
-
## Changes Between 0.2.2 and 0.2.3
|
28
25
|
|
29
|
-
|
30
|
-
### [Support for custom adapter per job](https://github.com/veeqo/advanced-sneakers-activejob/pull/4)
|
26
|
+
## [0.3.5](https://github.com/veeqo/advanced-sneakers-activejob/compare/v0.3.4...v0.3.5) - 2020-06-27
|
31
27
|
|
32
|
-
|
28
|
+
### Fixed
|
29
|
+
- [#11](https://github.com/veeqo/advanced-sneakers-activejob/pull/11) `NoMethodError` on `Rails.application.eager_load!` in Rails initializer
|
33
30
|
|
34
|
-
Cleanup of `puts` and logger mistakenly introduced in previous version
|
35
31
|
|
36
|
-
##
|
32
|
+
## [0.3.4](https://github.com/veeqo/advanced-sneakers-activejob/compare/v0.3.3...v0.3.4) - 2020-06-11
|
37
33
|
|
38
|
-
###
|
34
|
+
### Added
|
35
|
+
- [#10](https://github.com/veeqo/advanced-sneakers-activejob/pull/10) Ability to run ActiveJob consumers by wildcards for queue names
|
39
36
|
|
40
|
-
Fixed worker class name in rake task description
|
41
37
|
|
42
|
-
##
|
38
|
+
## [0.3.3](https://github.com/veeqo/advanced-sneakers-activejob/compare/v0.3.2...v0.3.3) - 2020-06-09
|
43
39
|
|
44
|
-
###
|
40
|
+
### Added
|
41
|
+
- [#9](https://github.com/veeqo/advanced-sneakers-activejob/pull/9) Ability to run ActiveJob consumers by queue names
|
45
42
|
|
46
|
-
Customizable options for message publishing (`routing_key`, `headers`, etc)
|
47
43
|
|
48
|
-
##
|
44
|
+
## [0.3.2](https://github.com/veeqo/advanced-sneakers-activejob/compare/v0.3.1...v0.3.2) - 2020-06-05
|
45
|
+
|
46
|
+
### Added
|
47
|
+
- [#8](https://github.com/veeqo/advanced-sneakers-activejob/pull/8) Ability to run specified ActiveJob queues consumers
|
48
|
+
|
49
|
+
|
50
|
+
## [0.3.1](https://github.com/veeqo/advanced-sneakers-activejob/compare/v0.3.0...v0.3.1) - 2020-06-02
|
51
|
+
|
52
|
+
### Fixed
|
53
|
+
- [#6](https://github.com/veeqo/advanced-sneakers-activejob/pull/6) Restore Sneakers::Worker::Classes methods
|
54
|
+
|
55
|
+
|
56
|
+
## [0.3.0](https://github.com/veeqo/advanced-sneakers-activejob/compare/v0.2.3...v0.3.0) - 2020-05-21
|
57
|
+
|
58
|
+
### Changed
|
59
|
+
- [#5](https://github.com/veeqo/advanced-sneakers-activejob/pull/5) Publisher is extracted to [bunny-publisher](https://github.com/veeqo/bunny-publisher)
|
60
|
+
|
61
|
+
|
62
|
+
## [0.2.3](https://github.com/veeqo/advanced-sneakers-activejob/compare/v0.2.2...v0.2.3) - 2020-04-06
|
63
|
+
|
64
|
+
### Added
|
65
|
+
- [#4](https://github.com/veeqo/advanced-sneakers-activejob/pull/4) Support for custom adapter per job
|
66
|
+
|
67
|
+
### Changed
|
68
|
+
- [#3](https://github.com/veeqo/advanced-sneakers-activejob/pull/3) Refactored support for ActiveJob prefix
|
69
|
+
|
70
|
+
|
71
|
+
## [0.2.2](https://github.com/veeqo/advanced-sneakers-activejob/compare/v0.2.1...v0.2.2) - 2020-04-05
|
72
|
+
|
73
|
+
### Fixed
|
74
|
+
- Cleanup of `puts` and logger mistakenly introduced in version `0.2.1`
|
75
|
+
|
76
|
+
## [0.2.1](https://github.com/veeqo/advanced-sneakers-activejob/compare/v0.2.0...v0.2.1) - 2020-04-05
|
77
|
+
|
78
|
+
### Added
|
79
|
+
- [#2](https://github.com/veeqo/advanced-sneakers-activejob/pull/2) Support queue name prefixes
|
80
|
+
|
81
|
+
|
82
|
+
## [0.2.0](https://github.com/veeqo/advanced-sneakers-activejob/compare/v0.1.0...v0.2.0) - 2020-03-23
|
83
|
+
|
84
|
+
### Added
|
85
|
+
- [#1](https://github.com/veeqo/advanced-sneakers-activejob/pull/1) Customizable options for message publishing (`routing_key`, `headers`, etc)
|
86
|
+
|
87
|
+
|
88
|
+
## [0.1.0](https://github.com/veeqo/advanced-sneakers-activejob/releases/tag/v0.1.0) - 2020-03-19
|
89
|
+
|
90
|
+
### Added
|
91
|
+
- `:advanced_sneakers` adapter for ActiveJob
|
data/Gemfile
CHANGED
@@ -2,10 +2,6 @@
|
|
2
2
|
|
3
3
|
source 'https://rubygems.org'
|
4
4
|
|
5
|
-
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
6
|
-
|
7
|
-
# Specify your gem's dependencies in advanced-sneakers-activejob.gemspec
|
8
5
|
gemspec
|
9
6
|
|
10
|
-
gem 'rails'
|
11
|
-
gem 'sneakers', ENV.fetch('SNEAKERS_VERSION', '~> 2.11')
|
7
|
+
gem 'rails'
|
data/README.md
CHANGED
@@ -34,11 +34,22 @@ Or install it yourself as:
|
|
34
34
|
config.active_job.queue_adapter = :advanced_sneakers
|
35
35
|
```
|
36
36
|
|
37
|
-
Run worker
|
37
|
+
Run worker for all queues of ActiveJob
|
38
38
|
```sh
|
39
39
|
rake sneakers:active_job
|
40
40
|
```
|
41
41
|
|
42
|
+
Run worker for picked queues of ActiveJob
|
43
|
+
```sh
|
44
|
+
QUEUES=mailers,foo,bar rake sneakers:active_job
|
45
|
+
```
|
46
|
+
|
47
|
+
Wildcards are supported for queues names with "words" (separator is `.`). Algorithm is similar to the way the [topic exchange matches routing keys](https://www.rabbitmq.com/tutorials/tutorial-five-python.html). `*` (star) substitutes for exactly one word. `#` (hash) substitutes for zero or more words
|
48
|
+
|
49
|
+
```sh
|
50
|
+
QUEUES=mailers,index.*,telemetery.# rake sneakers:active_job
|
51
|
+
```
|
52
|
+
|
42
53
|
## Unrouted messages
|
43
54
|
|
44
55
|
If message is published before routing has been configured (e.g. by consumer), it might be lost. To mitigate this problem the adapter uses [:mandatory](http://rubybunny.info/articles/exchanges.html#publishing_messages_as_mandatory) option for publishing messages. RabbitMQ returns unrouted messages back and the publisher is able to handle them:
|
@@ -55,7 +66,7 @@ Take into accout that **this process is asynchronous**. It means that in case of
|
|
55
66
|
|
56
67
|
## Custom message options
|
57
68
|
|
58
|
-
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.
|
59
70
|
|
60
71
|
```ruby
|
61
72
|
class MyJob < ActiveJob::Base
|
@@ -85,6 +96,14 @@ class MyJob < ActiveJob::Base
|
|
85
96
|
end
|
86
97
|
```
|
87
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
|
88
107
|
|
89
108
|
Take into accout that **custom message options are used for publishing only**.
|
90
109
|
|
@@ -30,10 +30,9 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.add_dependency 'bunny-publisher', '~> 0.1'
|
31
31
|
spec.add_dependency 'sneakers', '~> 2.7'
|
32
32
|
|
33
|
+
spec.add_development_dependency 'appraisal', '~> 2.3.0'
|
33
34
|
spec.add_development_dependency 'bundler'
|
34
35
|
spec.add_development_dependency 'pry-byebug'
|
35
36
|
spec.add_development_dependency 'rabbitmq_http_api_client', '~> 1.13'
|
36
|
-
spec.add_development_dependency '
|
37
|
-
spec.add_development_dependency 'rake'
|
38
|
-
spec.add_development_dependency 'rspec'
|
37
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
39
38
|
end
|
@@ -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+
|
@@ -21,6 +21,14 @@ require 'advanced_sneakers_activejob/active_job_patch'
|
|
21
21
|
require 'advanced_sneakers_activejob/railtie' if defined?(::Rails::Railtie)
|
22
22
|
require 'active_job/queue_adapters/advanced_sneakers_adapter'
|
23
23
|
|
24
|
+
ActiveSupport.on_load(:active_job) do
|
25
|
+
ActiveJob::Base.include AdvancedSneakersActiveJob::ActiveJobPatch
|
26
|
+
end
|
27
|
+
|
28
|
+
ActiveSupport.on_load(:action_mailer) do
|
29
|
+
require 'action_mailer/delivery_job' # Enforce definition of ActionMailer::DeliveryJob::Consumer
|
30
|
+
end
|
31
|
+
|
24
32
|
# Advanced Sneakers adapter for ActiveJob
|
25
33
|
module AdvancedSneakersActiveJob
|
26
34
|
class << self
|
@@ -46,11 +54,11 @@ module AdvancedSneakersActiveJob
|
|
46
54
|
end
|
47
55
|
|
48
56
|
def publisher
|
49
|
-
@publisher ||= AdvancedSneakersActiveJob::Publisher.new(config.publisher_config)
|
57
|
+
@publisher ||= AdvancedSneakersActiveJob::Publisher.new(**config.publisher_config)
|
50
58
|
end
|
51
59
|
|
52
60
|
def delayed_publisher
|
53
|
-
@delayed_publisher ||= AdvancedSneakersActiveJob::DelayedPublisher.new(config.publisher_config)
|
61
|
+
@delayed_publisher ||= AdvancedSneakersActiveJob::DelayedPublisher.new(**config.publisher_config)
|
54
62
|
end
|
55
63
|
|
56
64
|
# Based on ActiveSupport::Inflector#parameterize
|
@@ -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
|
@@ -3,18 +3,6 @@
|
|
3
3
|
module AdvancedSneakersActiveJob
|
4
4
|
# Rails integration
|
5
5
|
class Railtie < ::Rails::Railtie
|
6
|
-
initializer 'advanced_sneakers_activejob.discover_mailer_job' do
|
7
|
-
ActiveSupport.on_load(:action_mailer) do
|
8
|
-
require 'action_mailer/delivery_job' # Enforce definition of ActionMailer::DeliveryJob::Consumer
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
initializer 'advanced_sneakers_activejob.discover_default_job' do
|
13
|
-
ActiveSupport.on_load(:active_job) do
|
14
|
-
ActiveJob::Base.include AdvancedSneakersActiveJob::ActiveJobPatch
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
6
|
rake_tasks do
|
19
7
|
require 'advanced_sneakers_activejob/tasks'
|
20
8
|
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module AdvancedSneakersActiveJob
|
4
|
+
module Support
|
5
|
+
class LocateWorkersByQueues
|
6
|
+
def initialize(queues)
|
7
|
+
@queues = queues.uniq.reject(&:blank?)
|
8
|
+
@queues_without_workers = []
|
9
|
+
@workers = []
|
10
|
+
end
|
11
|
+
|
12
|
+
def call
|
13
|
+
detect_workers_for_queues!
|
14
|
+
ensure_all_workers_found!
|
15
|
+
|
16
|
+
@workers.uniq
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def ensure_all_workers_found!
|
22
|
+
return if @queues_without_workers.empty?
|
23
|
+
|
24
|
+
raise("Missing workers for queues: #{@queues_without_workers.join(', ')}")
|
25
|
+
end
|
26
|
+
|
27
|
+
def all_workers
|
28
|
+
@all_workers ||= Sneakers::Worker::Classes.activejob_workers
|
29
|
+
end
|
30
|
+
|
31
|
+
def detect_workers_for_queues!
|
32
|
+
@queues.each do |queue|
|
33
|
+
matching_workers = all_workers.select { |klass| klass.queue_name.match?(queue_regex(queue)) }
|
34
|
+
|
35
|
+
if matching_workers.any?
|
36
|
+
@workers += matching_workers
|
37
|
+
else
|
38
|
+
@queues_without_workers << queue
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# https://www.rabbitmq.com/tutorials/tutorial-five-python.html
|
44
|
+
def queue_regex(queue)
|
45
|
+
regex = Regexp.escape(queue)
|
46
|
+
.gsub(/\A\\\*|(\.)\\\*/, '\1[^\.]+') # "*" (star) substitutes for exactly one word
|
47
|
+
.sub('\.\#', '(\.[^\.]+)*') # "#" (hash) substitutes for zero or more words
|
48
|
+
|
49
|
+
Regexp.new(['\A', regex, '\z'].join)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -5,10 +5,12 @@ require 'sneakers/tasks'
|
|
5
5
|
task :environment
|
6
6
|
|
7
7
|
namespace :sneakers do
|
8
|
-
desc 'Start work for ActiveJob only (set $
|
8
|
+
desc 'Start work for ActiveJob only (set $QUEUES=foo,bar.baz for processing of "foo" and "bar.baz" queues)'
|
9
9
|
task :active_job do
|
10
10
|
Rake::Task['environment'].invoke
|
11
11
|
|
12
|
+
populate_workers_by_queues if ENV['WORKERS'].blank? && ENV['QUEUES'].present?
|
13
|
+
|
12
14
|
# Enforsing ActiveJob-only workers
|
13
15
|
AdvancedSneakersActiveJob.configure { |c| c.activejob_workers_strategy = :only }
|
14
16
|
|
@@ -18,4 +20,14 @@ namespace :sneakers do
|
|
18
20
|
|
19
21
|
Rake::Task['sneakers:run'].invoke
|
20
22
|
end
|
23
|
+
|
24
|
+
def populate_workers_by_queues
|
25
|
+
require 'advanced_sneakers_activejob/support/locate_workers_by_queues'
|
26
|
+
::Rails.application.eager_load!
|
27
|
+
|
28
|
+
queues = ENV['QUEUES'].split(',')
|
29
|
+
workers = AdvancedSneakersActiveJob::Support::LocateWorkersByQueues.new(queues).call
|
30
|
+
|
31
|
+
ENV['WORKERS'] = workers.map(&:name).join(',')
|
32
|
+
end
|
21
33
|
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
|
@@ -54,21 +54,21 @@ dependencies:
|
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '2.7'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
|
-
name:
|
57
|
+
name: appraisal
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
|
-
- - "
|
60
|
+
- - "~>"
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version:
|
62
|
+
version: 2.3.0
|
63
63
|
type: :development
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
|
-
- - "
|
67
|
+
- - "~>"
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version:
|
69
|
+
version: 2.3.0
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
|
-
name:
|
71
|
+
name: bundler
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
74
|
- - ">="
|
@@ -82,61 +82,47 @@ dependencies:
|
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: '0'
|
84
84
|
- !ruby/object:Gem::Dependency
|
85
|
-
name:
|
86
|
-
requirement: !ruby/object:Gem::Requirement
|
87
|
-
requirements:
|
88
|
-
- - "~>"
|
89
|
-
- !ruby/object:Gem::Version
|
90
|
-
version: '1.13'
|
91
|
-
type: :development
|
92
|
-
prerelease: false
|
93
|
-
version_requirements: !ruby/object:Gem::Requirement
|
94
|
-
requirements:
|
95
|
-
- - "~>"
|
96
|
-
- !ruby/object:Gem::Version
|
97
|
-
version: '1.13'
|
98
|
-
- !ruby/object:Gem::Dependency
|
99
|
-
name: rails
|
85
|
+
name: pry-byebug
|
100
86
|
requirement: !ruby/object:Gem::Requirement
|
101
87
|
requirements:
|
102
88
|
- - ">="
|
103
89
|
- !ruby/object:Gem::Version
|
104
|
-
version: '
|
90
|
+
version: '0'
|
105
91
|
type: :development
|
106
92
|
prerelease: false
|
107
93
|
version_requirements: !ruby/object:Gem::Requirement
|
108
94
|
requirements:
|
109
95
|
- - ">="
|
110
96
|
- !ruby/object:Gem::Version
|
111
|
-
version: '
|
97
|
+
version: '0'
|
112
98
|
- !ruby/object:Gem::Dependency
|
113
|
-
name:
|
99
|
+
name: rabbitmq_http_api_client
|
114
100
|
requirement: !ruby/object:Gem::Requirement
|
115
101
|
requirements:
|
116
|
-
- - "
|
102
|
+
- - "~>"
|
117
103
|
- !ruby/object:Gem::Version
|
118
|
-
version: '
|
104
|
+
version: '1.13'
|
119
105
|
type: :development
|
120
106
|
prerelease: false
|
121
107
|
version_requirements: !ruby/object:Gem::Requirement
|
122
108
|
requirements:
|
123
|
-
- - "
|
109
|
+
- - "~>"
|
124
110
|
- !ruby/object:Gem::Version
|
125
|
-
version: '
|
111
|
+
version: '1.13'
|
126
112
|
- !ruby/object:Gem::Dependency
|
127
113
|
name: rspec
|
128
114
|
requirement: !ruby/object:Gem::Requirement
|
129
115
|
requirements:
|
130
|
-
- - "
|
116
|
+
- - "~>"
|
131
117
|
- !ruby/object:Gem::Version
|
132
|
-
version: '0'
|
118
|
+
version: '3.0'
|
133
119
|
type: :development
|
134
120
|
prerelease: false
|
135
121
|
version_requirements: !ruby/object:Gem::Requirement
|
136
122
|
requirements:
|
137
|
-
- - "
|
123
|
+
- - "~>"
|
138
124
|
- !ruby/object:Gem::Version
|
139
|
-
version: '0'
|
125
|
+
version: '3.0'
|
140
126
|
description: Advanced Sneakers adapter for ActiveJob
|
141
127
|
email:
|
142
128
|
- rustam@sharshenov.com
|
@@ -149,12 +135,17 @@ files:
|
|
149
135
|
- ".rspec"
|
150
136
|
- ".rubocop.yml"
|
151
137
|
- ".travis.yml"
|
138
|
+
- Appraisals
|
152
139
|
- CHANGELOG.md
|
153
140
|
- Gemfile
|
154
141
|
- LICENSE.txt
|
155
142
|
- README.md
|
156
143
|
- Rakefile
|
157
144
|
- advanced-sneakers-activejob.gemspec
|
145
|
+
- gemfiles/.bundle/config
|
146
|
+
- gemfiles/activejob_4.2.x.gemfile
|
147
|
+
- gemfiles/activejob_5.2.x.gemfile
|
148
|
+
- gemfiles/activejob_6.0.x.gemfile
|
158
149
|
- lib/active_job/queue_adapters/advanced_sneakers_adapter.rb
|
159
150
|
- lib/advanced/sneakers/activejob.rb
|
160
151
|
- lib/advanced_sneakers_activejob.rb
|
@@ -167,6 +158,7 @@ files:
|
|
167
158
|
- lib/advanced_sneakers_activejob/handler.rb
|
168
159
|
- lib/advanced_sneakers_activejob/publisher.rb
|
169
160
|
- lib/advanced_sneakers_activejob/railtie.rb
|
161
|
+
- lib/advanced_sneakers_activejob/support/locate_workers_by_queues.rb
|
170
162
|
- lib/advanced_sneakers_activejob/tasks.rb
|
171
163
|
- lib/advanced_sneakers_activejob/version.rb
|
172
164
|
- lib/advanced_sneakers_activejob/workers_registry.rb
|
@@ -192,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
192
184
|
- !ruby/object:Gem::Version
|
193
185
|
version: '0'
|
194
186
|
requirements: []
|
195
|
-
rubygems_version: 3.
|
187
|
+
rubygems_version: 3.1.2
|
196
188
|
signing_key:
|
197
189
|
specification_version: 4
|
198
190
|
summary: Advanced Sneakers adapter for ActiveJob
|