New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make QueueConfigurer aware of DLX so dependency can be established #2

Merged
merged 1 commit into from Apr 23, 2015
Jump to file or symbol
Failed to load files and symbols.
+25 −0
Diff settings

Always

Just for now

@@ -45,6 +45,12 @@ def __init__(self, name, **kwargs):
convert(create_args, 'arguments', parse_dict)
self.create_args = create_args
dlx = create_args \
.get('arguments', {}) \
.get('x-dead-letter-exchange', None)
if dlx:
self.depends_on(dlx)
def start(self, channel):
_log.debug("Declaring queue %s (%r)", self.queue, self.create_args)
@@ -1,6 +1,8 @@
from nose.tools import eq_
from mock import Mock, call
from sparkplug.config.queue import QueueConfigurer
from sparkplug.config.exchange import ExchangeConfigurer
from sparkplug.config import calculate_dependencies
def test_queue_configurer_arguments_not_passed():
@@ -21,3 +23,20 @@ def test_queue_configurer_takes_arguments():
'x-dead-letter-exchange': 'dlx',
'x-ttl': 6000})],
channel.queue_declare.call_args_list)
def test_dead_letter_exchange_should_be_declared_first():
q = QueueConfigurer('q')
dlq = QueueConfigurer(
'dlq',
arguments="""{
"x-dead-letter-exchange": "dlx",
"x-dead-letter-routing-key": "q"}""")
dlx = ExchangeConfigurer('dlx', 'direct')
ordered_deps = calculate_dependencies({
'q': q,
'dlq': dlq,
'dlx': dlx
})
# because dlq needs dlx, dlx should be declared before dlq
assert ordered_deps.index(dlx) < ordered_deps.index(dlq)
ProTip! Use n and p to navigate between commits in a pull request.