basquiat 1.2.0 → 1.3.0.pre.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.codeclimate.yml +50 -0
- data/.gitignore +1 -0
- data/.metrics +1 -5
- data/.reek +0 -1
- data/.rubocop.yml +2 -1
- data/.ruby-version +1 -1
- data/Guardfile +4 -0
- data/README.md +77 -61
- data/basquiat.gemspec +5 -4
- data/basquiat_docker.sh +1 -1
- data/docker/Dockerfile +8 -3
- data/docker-compose.yml +3 -3
- data/lib/basquiat/adapters/base_adapter.rb +42 -7
- data/lib/basquiat/adapters/base_message.rb +14 -9
- data/lib/basquiat/adapters/rabbitmq/configuration.rb +31 -16
- data/lib/basquiat/adapters/rabbitmq/connection.rb +33 -56
- data/lib/basquiat/adapters/rabbitmq/events.rb +1 -1
- data/lib/basquiat/adapters/rabbitmq/message.rb +10 -9
- data/lib/basquiat/adapters/rabbitmq/requeue_strategies/auto_acknowledge.rb +15 -0
- data/lib/basquiat/adapters/rabbitmq/requeue_strategies/base_strategy.rb +8 -4
- data/lib/basquiat/adapters/rabbitmq/requeue_strategies/basic_acknowledge.rb +1 -1
- data/lib/basquiat/adapters/rabbitmq/requeue_strategies/dead_lettering.rb +16 -15
- data/lib/basquiat/adapters/rabbitmq/requeue_strategies/delayed_delivery.rb +80 -16
- data/lib/basquiat/adapters/rabbitmq/requeue_strategies.rb +7 -0
- data/lib/basquiat/adapters/rabbitmq/session.rb +12 -14
- data/lib/basquiat/adapters/rabbitmq_adapter.rb +35 -16
- data/lib/basquiat/adapters/test_adapter.rb +2 -5
- data/lib/basquiat/errors/strategy_not_registered.rb +1 -9
- data/lib/basquiat/interfaces/base.rb +28 -7
- data/lib/basquiat/support/configuration.rb +33 -4
- data/lib/basquiat/support/hash_refinements.rb +9 -0
- data/lib/basquiat/support/json.rb +9 -0
- data/lib/basquiat/version.rb +1 -1
- data/lib/basquiat.rb +6 -1
- data/spec/lib/adapters/base_adapter_spec.rb +1 -1
- data/spec/lib/adapters/base_message_spec.rb +0 -6
- data/spec/lib/adapters/rabbitmq/configuration_spec.rb +2 -2
- data/spec/lib/adapters/rabbitmq/connection_spec.rb +8 -13
- data/spec/lib/adapters/rabbitmq/events_spec.rb +8 -1
- data/spec/lib/adapters/rabbitmq/requeue_strategies/auto_acknowledge_spec.rb +24 -0
- data/spec/lib/adapters/rabbitmq/requeue_strategies/basic_acknowledge_spec.rb +4 -4
- data/spec/lib/adapters/rabbitmq/requeue_strategies/dead_lettering_spec.rb +23 -28
- data/spec/lib/adapters/rabbitmq/requeue_strategies/delayed_delivery_spec.rb +105 -0
- data/spec/lib/adapters/rabbitmq_adapter_spec.rb +21 -17
- data/spec/lib/basquiat_spec.rb +0 -6
- data/spec/lib/interfaces/base_spec.rb +11 -19
- data/spec/lib/support/configuration_spec.rb +0 -8
- data/spec/lib/support/hash_refinements_spec.rb +2 -2
- data/spec/spec_helper.rb +2 -6
- data/spec/support/rabbitmq_queue_matchers.rb +9 -3
- metadata +21 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e62fb7f48142250951c4e6c7d471fe3bbff47f4
|
4
|
+
data.tar.gz: 044bfbfdeeeec35150d679eae3425db38ab3699e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd73d055c57de8b20fd623876d270d18ddd8f0f8fd29443e76610dbd00c30dc5011010e49b1c3fa0f21a457a43a4a74f49ecdbe35db04e0b3bf9c759b743e545
|
7
|
+
data.tar.gz: e8e3af0254e4693d759defe4724f02bb4a6408c98df126303b214f491023fce078c57308967dbf37c72ded09d4eacb569b6d08cc3fc6db068e05cf55f04988dc
|
data/.codeclimate.yml
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# This is a sample .codeclimate.yml configured for Engine analysis on Code
|
2
|
+
# Climate Platform. For an overview of the Code Climate Platform, see here:
|
3
|
+
# http://docs.codeclimate.com/article/300-the-codeclimate-platform
|
4
|
+
|
5
|
+
# Under the engines key, you can configure which engines will analyze your repo.
|
6
|
+
# Each key is an engine name. For each value, you need to specify enabled: true
|
7
|
+
# to enable the engine as well as any other engines-specific configuration.
|
8
|
+
|
9
|
+
# For more details, see here:
|
10
|
+
# http://docs.codeclimate.com/article/289-configuring-your-repository-via-codeclimate-yml#platform
|
11
|
+
|
12
|
+
# For a list of all available engines, see here:
|
13
|
+
# http://docs.codeclimate.com/article/296-engines-available-engines
|
14
|
+
|
15
|
+
engines:
|
16
|
+
# to turn on an engine, add it here and set enabled to `true`
|
17
|
+
# to turn off an engine, set enabled to `false` or remove it
|
18
|
+
rubocop:
|
19
|
+
enabled: true
|
20
|
+
golint:
|
21
|
+
enabled: false
|
22
|
+
gofmt:
|
23
|
+
enabled: false
|
24
|
+
eslint:
|
25
|
+
enabled: false
|
26
|
+
csslint:
|
27
|
+
enabled: false
|
28
|
+
|
29
|
+
# Engines can analyze files and report issues on them, but you can separately
|
30
|
+
# decide which files will receive ratings based on those issues. This is
|
31
|
+
# specified by path patterns under the ratings key.
|
32
|
+
|
33
|
+
# For more details see here:
|
34
|
+
# http://docs.codeclimate.com/article/289-configuring-your-repository-via-codeclimate-yml#platform
|
35
|
+
|
36
|
+
# Note: If the ratings key is not specified, this will result in a 0.0 GPA on your dashboard.
|
37
|
+
|
38
|
+
# ratings:
|
39
|
+
# paths:
|
40
|
+
# - app/**
|
41
|
+
# - lib/**
|
42
|
+
# - "**.rb"
|
43
|
+
# - "**.go"
|
44
|
+
|
45
|
+
# You can globally exclude files from being analyzed by any engine using the
|
46
|
+
# exclude_paths key.
|
47
|
+
|
48
|
+
#exclude_paths:
|
49
|
+
#- spec/**/*
|
50
|
+
#- vendor/**/*
|
data/.gitignore
CHANGED
data/.metrics
CHANGED
data/.reek
CHANGED
data/.rubocop.yml
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby-2.2
|
1
|
+
ruby-2.2.3
|
data/Guardfile
CHANGED
data/README.md
CHANGED
@@ -1,97 +1,113 @@
|
|
1
1
|
# Basquiat
|
2
2
|
|
3
|
-
|
3
|
+
[](https://codeclimate.com/github/VAGAScom/basquiat)
|
4
4
|
|
5
|
-
|
5
|
+
**Basquiat** is library aimed to hide (almost) all the complexity when working with some kind of message queue from the application internals.
|
6
|
+
|
7
|
+
All the exchanges, connections, queues and sessions declarations are swept under rug. The aim is to provide a simple yet flexible interface to work with message queues.
|
6
8
|
|
7
9
|
## Installation
|
8
10
|
|
9
11
|
Add this line to your application's Gemfile:
|
10
12
|
|
11
|
-
|
13
|
+
```ruby
|
14
|
+
gem 'basquiat'
|
15
|
+
```
|
12
16
|
|
13
17
|
And then execute:
|
14
18
|
|
15
|
-
|
19
|
+
```bash
|
20
|
+
$ bundle
|
21
|
+
```
|
16
22
|
|
17
23
|
Or install it yourself as:
|
18
24
|
|
19
|
-
|
25
|
+
```bash
|
26
|
+
$ gem install basquiat
|
27
|
+
```
|
20
28
|
|
21
|
-
You will also need the right gem for your MQ system. Bundled in this gem you will find
|
29
|
+
You will also need the right gem for your Message Queue (MQ) system. Bundled in this gem you will find 1 adapter, for RabbitMQ, which depends on the gem _bunny_.
|
22
30
|
|
23
31
|
## Basic Usage
|
24
32
|
|
25
|
-
First of all require the gem, the
|
26
|
-
|
27
|
-
require 'basquiat'
|
28
|
-
require 'bunny'
|
29
|
-
require 'basquiat/adapters/rabbitmq_adapter'
|
33
|
+
First of all require the gem, the dependency for the adapter and the adapter itself
|
30
34
|
|
31
|
-
|
35
|
+
```ruby
|
36
|
+
require 'basquiat'
|
37
|
+
require 'bunny'
|
38
|
+
require 'basquiat/adapters/rabbitmq_adapter'
|
39
|
+
```
|
32
40
|
|
33
|
-
|
34
|
-
extend Basquiat::Base
|
35
|
-
end
|
41
|
+
Then you can extend the class that you will use for communicating with the MQ, setting the adapter:
|
36
42
|
|
37
|
-
|
38
|
-
|
39
|
-
|
43
|
+
```ruby
|
44
|
+
class TownCrier
|
45
|
+
extend Basquiat::Base
|
46
|
+
self.event_adapter Basquiat::Adapters::RabbitMq
|
47
|
+
end
|
48
|
+
```
|
49
|
+
From there you can publish events to the queue
|
40
50
|
|
51
|
+
```ruby
|
52
|
+
TownCrier.publish('some.nifty.event', {a: 'hash', of: 'values'})
|
53
|
+
```
|
41
54
|
And you can subscribe to one or more events using a proc that will get called when the message is received:
|
42
55
|
|
43
|
-
|
44
|
-
|
56
|
+
```ruby
|
57
|
+
class TownCrier
|
58
|
+
extend Basquiat::Base
|
45
59
|
|
46
|
-
|
47
|
-
|
60
|
+
subscribe_to 'some.nifty.event', ->(msg) { msg.fetch(:of, '').upcase }
|
61
|
+
end
|
62
|
+
```
|
48
63
|
|
49
64
|
## Configuration
|
50
65
|
|
51
66
|
You can setup Basquiat using the configure method. This method will yield a Configuration object:
|
52
67
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
68
|
+
```ruby
|
69
|
+
Basquiat.configure do |config|
|
70
|
+
config.exchange_name = 'my_exchange'
|
71
|
+
end
|
72
|
+
```
|
57
73
|
The available options are:
|
58
74
|
|
59
75
|
- config_file= Receive a path to an YAML file (example here)
|
60
76
|
- queue_name= The default queue name
|
61
77
|
- exchange_name= The default exchange name
|
62
78
|
- environment= Forces the environment to something other than the value of BASQUIAT_ENV
|
63
|
-
- logger= The logger to be used. Defaults to a null logger.
|
64
|
-
|
65
|
-
The configuration can be reset using the Basquiat.reset method.
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
79
|
+
- logger= The logger to be used. Defaults to a null object logger.
|
80
|
+
|
81
|
+
The configuration can be reset using the `Basquiat.reset` method.
|
82
|
+
|
83
|
+
YAML File configuration example:
|
84
|
+
|
85
|
+
```yaml
|
86
|
+
test: #environment
|
87
|
+
default_adapter: Basquiat::Adapters::Test #it will overwrite the adapter on all classes that extend Basquiat::Base
|
88
|
+
adapter_options: #Adapter specific options
|
89
|
+
servers:
|
90
|
+
-
|
91
|
+
host: 'localhost'
|
92
|
+
port: '98765'
|
93
|
+
development: #full example of the RabbitMq options
|
94
|
+
exchange_name: 'basquiat.exchange'
|
95
|
+
queue_name: 'basquiat.queue'
|
96
|
+
default_adapter: Basquiat::Adapters::RabbitMq
|
97
|
+
adapter_options:
|
98
|
+
hosts:
|
99
|
+
- 'localhost'
|
100
|
+
port: 5672
|
101
|
+
publisher:
|
102
|
+
confirm: true
|
103
|
+
persistent: true
|
104
|
+
auth:
|
105
|
+
user: 'guest'
|
106
|
+
password: 'guest'
|
107
|
+
requeue:
|
108
|
+
enabled: true
|
109
|
+
delayed_delivery:
|
110
|
+
retries: 10
|
111
|
+
queue_name_preffix: wait.for_it
|
112
|
+
exchange_name: legendary
|
113
|
+
```
|
data/basquiat.gemspec
CHANGED
@@ -27,14 +27,15 @@ EOD
|
|
27
27
|
spec.add_development_dependency 'guard-bundler'
|
28
28
|
spec.add_development_dependency 'guard-rspec'
|
29
29
|
spec.add_development_dependency 'guard-rubocop'
|
30
|
+
spec.add_development_dependency 'guard-yard'
|
30
31
|
spec.add_development_dependency 'bunny'
|
31
|
-
spec.add_development_dependency 'stomp'
|
32
32
|
spec.add_development_dependency 'yajl-ruby'
|
33
33
|
spec.add_development_dependency 'simplecov'
|
34
|
-
spec.add_development_dependency 'metric_fu'
|
35
34
|
spec.add_development_dependency 'rubocop'
|
36
|
-
spec.add_development_dependency '
|
37
|
-
spec.add_development_dependency '
|
35
|
+
spec.add_development_dependency 'metric_fu'
|
36
|
+
spec.add_development_dependency 'codeclimate-test-reporter'
|
37
|
+
spec.add_development_dependency 'yard'
|
38
|
+
|
38
39
|
|
39
40
|
spec.add_dependency 'multi_json'
|
40
41
|
spec.add_dependency 'naught'
|
data/basquiat_docker.sh
CHANGED
data/docker/Dockerfile
CHANGED
@@ -1,10 +1,15 @@
|
|
1
|
-
FROM mereghost/ruby:
|
2
|
-
|
3
|
-
RUN useradd -m -g users dev
|
1
|
+
FROM mereghost/ruby:2.2.2
|
4
2
|
|
3
|
+
RUN useradd -mg users -G network dev
|
5
4
|
VOLUME /basquiat
|
6
5
|
WORKDIR /basquiat
|
7
6
|
|
8
7
|
ENV REFRESHED_AT 2015-03-29
|
8
|
+
USER dev
|
9
9
|
COPY Gemfile /tmp/Gemfile
|
10
|
+
|
11
|
+
#This is needed by bundler =/
|
12
|
+
ENV GEM_HOME=/home/dev/.gem
|
10
13
|
RUN cd /tmp && bundle install
|
14
|
+
|
15
|
+
EXPOSE 8808
|
data/docker-compose.yml
CHANGED
@@ -8,54 +8,89 @@ module Basquiat
|
|
8
8
|
using Basquiat::HashRefinements
|
9
9
|
|
10
10
|
class << self
|
11
|
+
# A hash representing the registered requeue/acknowledge strategies
|
12
|
+
# @return [Hash] the registered RequeueStrategies
|
11
13
|
def strategies
|
12
14
|
@strategies ||= {}
|
13
15
|
end
|
14
16
|
|
17
|
+
# Used to register a requeue/acknowledge strategy
|
18
|
+
# @param config_name [#to_sym] the named used on the config file for the Requeue Strategy
|
19
|
+
# @param klass [Class] the class name.
|
15
20
|
def register_strategy(config_name, klass)
|
16
|
-
strategies
|
21
|
+
strategies[config_name.to_sym] = klass
|
22
|
+
end
|
23
|
+
|
24
|
+
# Return the Strategy Class registered on key
|
25
|
+
# @param key [#to_sym] configured key for the wanted strategy
|
26
|
+
# @return [Class] return the strategy class
|
27
|
+
# @raise [Errors::StrategyNotRegistered] if it fails to find the key
|
28
|
+
def strategy(key)
|
29
|
+
strategies.fetch(key)
|
30
|
+
rescue KeyError
|
31
|
+
raise Basquiat::Errors::StrategyNotRegistered
|
17
32
|
end
|
18
33
|
end
|
19
34
|
|
20
|
-
|
35
|
+
# @param procs: [Object]
|
36
|
+
# It's a hash by default, but usually will be superseded by the adapter implementation
|
37
|
+
def initialize(procs: {})
|
21
38
|
@options = base_options
|
22
|
-
@procs =
|
39
|
+
@procs = procs
|
23
40
|
@retries = 0
|
24
41
|
end
|
25
42
|
|
43
|
+
# Utility method to access the class instance variable
|
26
44
|
def strategies
|
27
45
|
self.class.strategies
|
28
46
|
end
|
29
47
|
|
30
|
-
#
|
31
|
-
#
|
48
|
+
# Allows the #base_options to be superseded on the local level
|
49
|
+
#
|
50
|
+
# You could have configured an exchange_name (on a config file) to +'awesome.sauce'+,
|
51
|
+
# but on this object you'd want to publish your messages to the +'killer.mailman'+ exchange.
|
52
|
+
# @example
|
53
|
+
# class Mailmail
|
54
|
+
# extend Basquiat::Base
|
55
|
+
# adapter_options {exchange: {name: 'killer.mailman'}}
|
56
|
+
# end
|
57
|
+
#
|
32
58
|
# @param [Hash] opts an adapter dependant hash of options
|
33
59
|
def adapter_options(opts)
|
34
60
|
@options.deep_merge(opts)
|
35
61
|
end
|
36
62
|
|
37
|
-
#
|
38
|
-
# @
|
63
|
+
# The default adapter options, merged with the {Basquiat::Configuration#adapter_options}. Used internally.
|
64
|
+
# @todo rename this method
|
65
|
+
# @return [Hash] the full options hash
|
39
66
|
def base_options
|
40
67
|
default_options.merge(Basquiat.configuration.adapter_options)
|
41
68
|
end
|
42
69
|
|
70
|
+
# The adapter default options
|
71
|
+
# @return [Hash]
|
43
72
|
def default_options
|
44
73
|
{}
|
45
74
|
end
|
46
75
|
|
76
|
+
# @!group Adapter specific implementations
|
77
|
+
# @abstract Publish an event to the event stream
|
47
78
|
def publish
|
48
79
|
fail Basquiat::Errors::SubclassResponsibility
|
49
80
|
end
|
50
81
|
|
82
|
+
# @abstract subscribe_to the event stream
|
51
83
|
def subscribe_to
|
52
84
|
fail Basquiat::Errors::SubclassResponsibility
|
53
85
|
end
|
54
86
|
|
87
|
+
# @abstract Disconnect from the message queue
|
55
88
|
def disconnect
|
56
89
|
fail Basquiat::Errors::SubclassResponsibility
|
57
90
|
end
|
58
91
|
|
92
|
+
# @!endgroup
|
93
|
+
|
59
94
|
private
|
60
95
|
|
61
96
|
attr_reader :procs, :options
|
@@ -1,29 +1,34 @@
|
|
1
1
|
module Basquiat
|
2
2
|
module Adapters
|
3
|
+
# The simplest Message class. It's encouraged to tailor it to your adapter needs (hence BaseMessage).
|
3
4
|
class BaseMessage < SimpleDelegator
|
4
5
|
attr_reader :action
|
5
6
|
|
7
|
+
# @param message [Object] It's assumed that message is some kind of JSON
|
8
|
+
# @note All unknown messages will be delegated to the resulting Hash
|
6
9
|
def initialize(message)
|
7
10
|
@message = Basquiat::Json.decode(message)
|
8
11
|
super(@message)
|
9
12
|
@action = :ack
|
10
13
|
end
|
11
14
|
|
12
|
-
|
13
|
-
|
15
|
+
# @!group Action Setters
|
16
|
+
# Sets the action to be taken after processing to be an ack.
|
17
|
+
# Here just in case as the default is to acknowledge the message.
|
18
|
+
def ack
|
19
|
+
@action = :ack
|
14
20
|
end
|
15
21
|
|
16
|
-
|
17
|
-
|
22
|
+
# Sets the action to be taken after processing to be an nack / reject
|
23
|
+
def nack
|
24
|
+
@action = :nack
|
18
25
|
end
|
19
26
|
|
27
|
+
# Sets the action to be taken after processing to be a requeue
|
20
28
|
def requeue
|
21
|
-
|
22
|
-
end
|
23
|
-
|
24
|
-
def delay_redelivery
|
25
|
-
fail Basquiat::Errors::SubclassResponsibility
|
29
|
+
@action = :requeue
|
26
30
|
end
|
31
|
+
# @!endgroup
|
27
32
|
end
|
28
33
|
end
|
29
34
|
end
|
@@ -1,20 +1,26 @@
|
|
1
1
|
module Basquiat
|
2
2
|
module Adapters
|
3
3
|
class RabbitMq
|
4
|
+
# Responsible for dealing with the overall configuration of the RabbitMQ adapter
|
4
5
|
class Configuration
|
5
6
|
using Basquiat::HashRefinements
|
6
7
|
|
7
8
|
def initialize
|
8
|
-
@options = {
|
9
|
-
|
9
|
+
@options = { connection:
|
10
|
+
{ hosts: ['localhost'],
|
11
|
+
port: 5672,
|
12
|
+
auth: { user: 'guest', password: 'guest' }
|
13
|
+
},
|
10
14
|
queue: {
|
11
|
-
|
12
|
-
|
15
|
+
name: Basquiat.configuration.queue_name,
|
16
|
+
durable: true,
|
17
|
+
options: {} },
|
13
18
|
exchange: {
|
14
|
-
|
15
|
-
|
19
|
+
name: Basquiat.configuration.exchange_name,
|
20
|
+
durable: true,
|
21
|
+
options: {} },
|
16
22
|
publisher: { confirm: true, persistent: false },
|
17
|
-
|
23
|
+
consumer: { prefetch: 1000, manual_ack: true },
|
18
24
|
requeue: { enabled: false } }
|
19
25
|
end
|
20
26
|
|
@@ -22,29 +28,38 @@ module Basquiat
|
|
22
28
|
@options
|
23
29
|
end
|
24
30
|
|
25
|
-
|
31
|
+
# Merges the user supplied options with the base ones
|
32
|
+
# @param user_opts [Hash{Symbol=>Object}]
|
33
|
+
# @option user_opts [Hash{Symbol=>Object}] :connection see {Connection#initialize}
|
34
|
+
# @option user_opts [Hash{Symbol=>Object}] :queue
|
35
|
+
# @option user_opts [Hash{Symbol=>Object}] :exchange
|
36
|
+
# @option user_opts [Hash{Symbol=>Object}] :publisher
|
37
|
+
# @option user_opts [Hash{Symbol=>Object}] :requeue
|
38
|
+
# @return [Hash] the configuration option hash
|
39
|
+
def merge_user_options(**user_opts)
|
26
40
|
@options.merge!(user_opts)
|
27
41
|
end
|
28
42
|
|
43
|
+
# @return [Hash] the connection options
|
29
44
|
def connection_options
|
30
|
-
|
31
|
-
failover: @options[:failover],
|
32
|
-
auth: @options[:auth] }
|
45
|
+
@options[:connection]
|
33
46
|
end
|
34
47
|
|
48
|
+
# @return [Hash] the session options
|
35
49
|
def session_options
|
36
50
|
{ exchange: @options[:exchange],
|
37
51
|
publisher: @options[:publisher],
|
52
|
+
consumer: @options[:consumer],
|
38
53
|
queue: @options[:queue] }.deep_merge(strategy.session_options)
|
39
54
|
end
|
40
55
|
|
56
|
+
# @return [BaseStrategy] the requeue strategy or {BasicAcknowledge} if none is configured
|
41
57
|
def strategy
|
42
|
-
|
43
|
-
|
44
|
-
@strategy.
|
58
|
+
requeue = @options[:requeue]
|
59
|
+
return AutoAcknowledge unless requeue[:enabled]
|
60
|
+
@strategy ||= RabbitMq.strategy(requeue[:strategy].to_sym)
|
61
|
+
@strategy.setup(requeue[:options] || {})
|
45
62
|
@strategy
|
46
|
-
rescue KeyError
|
47
|
-
fail Basquiat::Errors::StrategyNotRegistered.new(@options[:requeue][:strategy])
|
48
63
|
end
|
49
64
|
end
|
50
65
|
end
|