Fixing MongoDB backend to work properly with TTL (#1076)

* Fixing MongoDB backend to work properly with TTL
Bumping pymongo version to 3.8.0

* Updating authors

* Adding dependencies to travis config

* Fixing travis test cases

* Changing pymongo version to align with mongo result backend
This commit is contained in:
Marcin Puhacz 2019-08-07 14:06:13 +02:00 committed by Omer Katz
parent 193054d243
commit 0ad7d08c4c
5 changed files with 17 additions and 9 deletions

View File

@ -15,10 +15,13 @@ matrix:
include: include:
- python: 2.7 - python: 2.7
env: TOXENV=2.7 env: TOXENV=2.7
before_install: sudo apt-get update && sudo apt-get install libgnutls-dev
- python: 3.5 - python: 3.5
env: TOXENV=3.5 env: TOXENV=3.5
before_install: sudo apt-get update && sudo apt-get install libgnutls-dev
- python: 3.6 - python: 3.6
env: TOXENV=3.6 env: TOXENV=3.6
before_install: sudo apt-get update && sudo apt-get install libgnutls-dev
- python: 3.7 - python: 3.7
env: TOXENV=3.7-linux env: TOXENV=3.7-linux
sudo: true sudo: true
@ -39,6 +42,7 @@ matrix:
- python: '3.6' - python: '3.6'
env: TOXENV=apicheck env: TOXENV=apicheck
stage: lint stage: lint
before_install: sudo apt-get update && sudo apt-get install libgnutls-dev
- python: '3.6' - python: '3.6'
env: TOXENV=pydocstyle env: TOXENV=pydocstyle
stage: lint stage: lint

View File

@ -87,6 +87,7 @@ Luyun Xie <2304310@qq.com>
Mads Jensen <https://github.com/atombrella> Mads Jensen <https://github.com/atombrella>
Mahendra M <Mahendra_M@infosys.com> Mahendra M <Mahendra_M@infosys.com>
Marcin Lulek (ergo) <info@webreactor.eu> Marcin Lulek (ergo) <info@webreactor.eu>
Marcin Puhacz <marcin.puhacz@gmail.com>
Mark Lavin <mlavin@caktusgroup.com> Mark Lavin <mlavin@caktusgroup.com>
markow <markow@red-sky.pl> markow <markow@red-sky.pl>
Matt Wise <wise@wiredgeek.net> Matt Wise <wise@wiredgeek.net>

View File

@ -20,6 +20,8 @@ from kombu.utils.json import loads, dumps
from kombu.utils.objects import cached_property from kombu.utils.objects import cached_property
from . import virtual from . import virtual
from .base import to_rabbitmq_queue_arguments
E_SERVER_VERSION = """\ E_SERVER_VERSION = """\
Kombu requires MongoDB version 1.3+ (server is {0})\ Kombu requires MongoDB version 1.3+ (server is {0})\
@ -286,6 +288,9 @@ class Channel(virtual.Channel):
options['readpreference'] = modes[options['readpreference']] options['readpreference'] = modes[options['readpreference']]
return options return options
def prepare_queue_arguments(self, arguments, **kwargs):
return to_rabbitmq_queue_arguments(arguments, **kwargs)
def _open(self, scheme='mongodb://'): def _open(self, scheme='mongodb://'):
hostname, dbname, conf = self._parse_uri(scheme=scheme) hostname, dbname, conf = self._parse_uri(scheme=scheme)
@ -427,11 +432,9 @@ class Channel(virtual.Channel):
return return
self.routing.update( self.routing.update(
{'queue': queue}, {'$set': {'expire_at': expire_at}}, {'queue': queue}, {'$set': {'expire_at': expire_at}}, multi=True)
multiple=True)
self.queues.update( self.queues.update(
{'_id': queue}, {'$set': {'expire_at': expire_at}}, {'_id': queue}, {'$set': {'expire_at': expire_at}}, multi=True)
multiple=True)
def get_now(self): def get_now(self):
"""Return current time in UTC.""" """Return current time in UTC."""

View File

@ -1 +1 @@
pymongo>=2.6.2,<3.0 pymongo>=3.3.0

View File

@ -418,7 +418,7 @@ class test_mongodb_channel_ttl(BaseMongoDBChannelCase):
'routing', 'update', 'routing', 'update',
{'queue': 'foobar'}, {'queue': 'foobar'},
{'$set': {'expire_at': self.expire_at}}, {'$set': {'expire_at': self.expire_at}},
multiple=True, multi=True,
) )
def test_put(self): def test_put(self):
@ -499,13 +499,13 @@ class test_mongodb_channel_ttl(BaseMongoDBChannelCase):
'routing', 'update', 'routing', 'update',
{'queue': 'foobar'}, {'queue': 'foobar'},
{'$set': {'expire_at': self.expire_at}}, {'$set': {'expire_at': self.expire_at}},
multiple=True, multi=True,
) )
self.assert_operation_called_with( self.assert_operation_called_with(
'queues', 'update', 'queues', 'update',
{'_id': 'foobar'}, {'_id': 'foobar'},
{'$set': {'expire_at': self.expire_at}}, {'$set': {'expire_at': self.expire_at}},
multiple=True, multi=True,
) )