From 89ce51d0637335b3c1423220ec10666bfdea08ec Mon Sep 17 00:00:00 2001 From: JimZhang Date: Mon, 22 Jan 2024 16:39:02 +0800 Subject: [PATCH] feat: support get queue name --- amqpworker/easyqueue/queue.py | 4 ++-- amqpworker/rabbitmq/message.py | 4 ++++ poetry.lock | 22 +++++++++++++++++++++- pyproject.toml | 3 ++- 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/amqpworker/easyqueue/queue.py b/amqpworker/easyqueue/queue.py index 9170217..22ae5dc 100644 --- a/amqpworker/easyqueue/queue.py +++ b/amqpworker/easyqueue/queue.py @@ -270,9 +270,9 @@ class JsonQueue(BaseQueue, Generic[T]): else: serialized_data = self.serialize(data) if properties is None: - properties = {'Content-Type': 'application/json'} + properties = {'content_type': 'application/json'} elif not properties.get('Content-Type'): - properties['Content-Type'] = 'application/json' + properties['content_type'] = 'application/json' if not isinstance(serialized_data, bytes): serialized_data = serialized_data.encode() diff --git a/amqpworker/rabbitmq/message.py b/amqpworker/rabbitmq/message.py index 1f3b2bb..61ebf34 100644 --- a/amqpworker/rabbitmq/message.py +++ b/amqpworker/rabbitmq/message.py @@ -20,6 +20,10 @@ class RabbitMQMessage: def body(self): return self._amqp_message.deserialized_data + @property + def queue_name(self): + return self._amqp_message.queue_name + @property def serialized_data(self): return self._amqp_message.serialized_data diff --git a/poetry.lock b/poetry.lock index 01ab83b..0774326 100644 --- a/poetry.lock +++ b/poetry.lock @@ -349,6 +349,26 @@ type = "legacy" url = "https://mirror.baidu.com/pypi/simple" reference = "douban" +[[package]] +name = "pyscan-rs" +version = "0.1.6" +description = "python dependency vulnerability scanner" +category = "dev" +optional = false +python-versions = ">=3.7" +files = [ + {file = "pyscan_rs-0.1.6-py3-none-macosx_10_7_x86_64.whl", hash = "sha256:3817087612e25c446f03cda60b38b91f4cf4e3d443ab431889ea58853f4492ab"}, + {file = "pyscan_rs-0.1.6-py3-none-macosx_11_0_arm64.whl", hash = "sha256:f5b18b3ed4e1a07bd4171ece221d15d2dc6190ff2ec601c8d70a1c3b77238638"}, + {file = "pyscan_rs-0.1.6-py3-none-win32.whl", hash = "sha256:f888cad16b13c49ff1b698724a3092348565776e68b17607b7645ca59e727912"}, + {file = "pyscan_rs-0.1.6-py3-none-win_amd64.whl", hash = "sha256:e6cfaee0d9af368b95e70fff33282bc79f8159fe8279697fc3d71a7bd62efd0d"}, + {file = "pyscan_rs-0.1.6.tar.gz", hash = "sha256:8102a51d8f52787f24f946fbcdd5b0c130ded0e2cff7ecd08a2746d8fc855a0f"}, +] + +[package.source] +type = "legacy" +url = "https://mirror.baidu.com/pypi/simple" +reference = "douban" + [[package]] name = "pytest" version = "7.4.0" @@ -457,4 +477,4 @@ reference = "douban" [metadata] lock-version = "2.0" python-versions = "^3.8" -content-hash = "c08ff79fd4eebe7caee4016755cdc0f354bd4db0271528a0cdbbc19b0dff89bb" +content-hash = "22a0dc2f63597c3debea2297e8aa2e4ce38235ac6f0b5aac1c88647e0d8fe23b" diff --git a/pyproject.toml b/pyproject.toml index 220e785..6cdef08 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "amqp-workers" -version = "0.1.3" +version = "0.1.5" description = "amqp-worker is a Python-based multi-threaded RabbitMQ consumer framework" authors = ["JimZhang "] readme = "README.md" @@ -23,6 +23,7 @@ orjson = "^3.9.10" pytest = "^7.3.1" pytest-mock = "^3.10.0" oxidized-importer = "^0.6.0" +pyscan-rs = "^0.1.6" [build-system] requires = ["poetry-core"]