feat(storage): do not restrict the container type
In Python, container is a concept, not a specific type. The original implementation limit the container to list, while this change allow you to use other containers, like tuple, to supply as a sequence of the message IDs. Change-Id: I347e764ed0e965f17aa49f3e80f2f100ba8ba495
This commit is contained in:
parent
0b2af6828a
commit
adf9a2e714
@ -188,8 +188,8 @@ class MessageBase(ControllerBase):
|
||||
:param queue: Name of the queue to get the
|
||||
message from.
|
||||
:param project: Project id
|
||||
:param message_ids: One or more message IDs. Can be a single
|
||||
string ID or a list of IDs.
|
||||
:param message_ids: One message ID or a
|
||||
sequence of message IDs.
|
||||
|
||||
:returns: An iterable, yielding dicts containing message details
|
||||
:raises: DoesNotExist
|
||||
|
@ -26,6 +26,7 @@ import datetime
|
||||
import time
|
||||
|
||||
import pymongo.errors
|
||||
import six
|
||||
|
||||
import marconi.openstack.common.log as logging
|
||||
from marconi.openstack.common import timeutils
|
||||
@ -367,7 +368,7 @@ class MessageController(storage.MessageBase):
|
||||
|
||||
@utils.raises_conn_error
|
||||
def get(self, queue, message_ids, project=None):
|
||||
if not isinstance(message_ids, list):
|
||||
if isinstance(message_ids, six.string_types):
|
||||
message_ids = [message_ids]
|
||||
|
||||
message_ids = [utils.to_oid(id) for id in message_ids]
|
||||
|
@ -14,6 +14,8 @@
|
||||
# limitations under the License.
|
||||
|
||||
|
||||
import six
|
||||
|
||||
from marconi.storage import base
|
||||
from marconi.storage import exceptions
|
||||
from marconi.storage.sqlite import utils
|
||||
@ -41,7 +43,7 @@ class MessageController(base.MessageBase):
|
||||
if project is None:
|
||||
project = ''
|
||||
|
||||
if not isinstance(message_ids, list):
|
||||
if isinstance(message_ids, six.string_types):
|
||||
message_ids = [message_ids]
|
||||
|
||||
message_ids = ["'%s'" % utils.msgid_decode(id) for id in message_ids]
|
||||
|
Loading…
x
Reference in New Issue
Block a user