Skip to content
Snippets Groups Projects
Commit e29e9a16 authored by Piotr Maślanka's avatar Piotr Maślanka Committed by GitHub
Browse files

Merge pull request #28 from smok-serwis/issue-26-pass-qos-as-int

fixes #26
parents 1b7c1619 dd310d48
No related branches found
No related tags found
No related merge requests found
...@@ -87,8 +87,10 @@ class Consumer(Channeler): ...@@ -87,8 +87,10 @@ class Consumer(Channeler):
:param on_message: callable that will process incoming messages :param on_message: callable that will process incoming messages
:type on_message: callable(ReceivedMessage instance) :type on_message: callable(ReceivedMessage instance)
:param no_ack: Will this consumer require acknowledges from messages? :param no_ack: Will this consumer require acknowledges from messages?
:param qos: a tuple of (prefetch size, prefetch window) for this consumer :param qos: a tuple of (prefetch size, prefetch window) for this consumer, or an int (prefetch window only)
:type qos: tuple(int, int) or tuple(None, int) If an int is passed, prefetch size will be set to 0 (which means undefined), and this int
will be used for prefetch window
:type qos: tuple(int, int) or tuple(None, int) or int
:param cancel_on_failure: Consumer will cancel itself when link goes down :param cancel_on_failure: Consumer will cancel itself when link goes down
:type cancel_on_failure: bool :type cancel_on_failure: bool
:param future_to_notify: Future to succeed when this consumer goes online for the first time. :param future_to_notify: Future to succeed when this consumer goes online for the first time.
...@@ -119,7 +121,9 @@ class Consumer(Channeler): ...@@ -119,7 +121,9 @@ class Consumer(Channeler):
# if this is not None, then it has an attribute # if this is not None, then it has an attribute
# on_cancel_customer(Consumer instance) # on_cancel_customer(Consumer instance)
if qos is not None: if qos is not None:
if qos[0] is None: if isinstance(qos, int):
qos = 0, qos
elif qos[0] is None:
qos = 0, qos[1] # prefetch_size=0=undefined qos = 0, qos[1] # prefetch_size=0=undefined
self.qos = qos self.qos = qos
self.qos_update_sent = False # QoS was not sent to server self.qos_update_sent = False # QoS was not sent to server
......
# coding=UTF-8
from __future__ import print_function, absolute_import, division
import six
import unittest
from coolamqp.attaches import Consumer
from coolamqp.objects import Queue
class TestConsumer(unittest.TestCase):
def test_issue_26(self):
"""Support for passing qos as int"""
cons = Consumer(Queue('wtf'), lambda msg: None, qos=25)
self.assertEquals(cons.qos, (0, 25))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment