Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

refactored queue_declare callback

  • Loading branch information...
commit c5ef4f102346f3f49e90922e3ada3bba7dc4e338 1 parent 6e6a4a0
@paolo-losi authored
View
2  TODO
@@ -1,6 +1,4 @@
* review of all methods
- - queue.unbind and queue.purge
- - refactor queue_declare callback
- basic.return
- basic.recover?
- tx.select, tx.commit, tx.rollback
View
6 examples/tutorial3/receive_logs.py
@@ -10,9 +10,9 @@ def on_connect():
ch.exchange_declare(exchange='logs', type='fanout')
ch.queue_declare(exclusive=True, callback=with_temp_queue)
-def with_temp_queue(queue_name, message_count, consumer_count):
- ch.queue_bind(exchange='logs', queue=queue_name)
- ch.consume(queue_name, callback, no_ack=True)
+def with_temp_queue(qinfo):
+ ch.queue_bind(exchange='logs', queue=qinfo.queue)
+ ch.consume(qinfo.queue, callback, no_ack=True)
def callback(msg):
print " [x] %r" % msg.body
View
6 examples/tutorial4/receive_logs_direct.py
@@ -16,12 +16,12 @@ def on_connect():
ch.exchange_declare(exchange='direct_logs', type='direct')
ch.queue_declare(exclusive=True, callback=with_temp_queue)
-def with_temp_queue(queue_name, message_count, consumer_count):
+def with_temp_queue(qinfo):
for severity in severities:
ch.queue_bind(exchange='direct_logs',
- queue=queue_name,
+ queue=qinfo.queue,
routing_key=severity)
- ch.consume(queue_name, callback, no_ack=True)
+ ch.consume(qinfo.queue, callback, no_ack=True)
def callback(msg):
print " [x] %r:%r" % (msg.rx_data.routing_key, msg.body)
View
6 examples/tutorial5/receive_logs_topic.py
@@ -16,12 +16,12 @@ def on_connect():
ch.exchange_declare(exchange='topic_logs', type='topic')
ch.queue_declare(exclusive=True, callback=with_temp_queue)
-def with_temp_queue(queue_name, message_count, consumer_count):
+def with_temp_queue(qinfo):
for binding_key in binding_keys:
ch.queue_bind(exchange='topic_logs',
- queue=queue_name,
+ queue=qinfo.queue,
routing_key=binding_key)
- ch.consume(queue_name, callback, no_ack=True)
+ ch.consume(qinfo.queue, callback, no_ack=True)
def callback(msg):
print " [x] %r:%r" % (msg.rx_data.routing_key, msg.body)
View
2  stormed/method/queue.py
@@ -4,7 +4,7 @@
@add_method(DeclareOk)
def handle(self, ch):
if ch.callback:
- ch.invoke_callback(self.queue, self.message_count, self.consumer_count)
+ ch.invoke_callback(self)
@add_method(PurgeOk)
def handle(self, channel):
View
8 test/test_channel.py
@@ -38,10 +38,10 @@ def on_connect():
def test_queue(self):
conn = Connection('localhost', io_loop=self.io_loop)
- def on_creation(queue, message_count, consumer_count):
- assert queue == 'test_queue'
- assert message_count == 0
- assert consumer_count == 0
+ def on_creation(qinfo):
+ assert qinfo.queue == 'test_queue'
+ assert qinfo.message_count == 0
+ assert qinfo.consumer_count == 0
def on_connect():
ch = conn.channel()
Please sign in to comment.
Something went wrong with that request. Please try again.