aio-rabbitmq-utils


Nameaio-rabbitmq-utils JSON
Version 1.0.8 PyPI version JSON
download
home_pageNone
SummaryA package for async communication with RabbitMQ
upload_time2024-10-17 17:18:00
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseMIT License Copyright (c) 2024 Omer Dagry Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords rabbitmq pika aio async
VCS
bugtrack_url
requirements setuptools aio-pika no-exception
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # RabbitMQUtils

### Example for reader
#### Consumer

```python
from aio_rabbitmq_utils import RabbitMQConsumeInputDeviceManager, RabbitMQInputConsumeDevice


async def example():
    input_device_manager = RabbitMQConsumeInputDeviceManager(
        hosts=["the", "rabbit", "hosts", ", will", "connect", "to", "only", "one"],
        user="user",
        password="password",
        vhost="/",
        prefetch_count=10,
    )
    await input_device_manager.connect()
    input_device: RabbitMQInputConsumeDevice = await input_device_manager.get_device("some_queue_name")
    await input_device.connect()
    data, headers, transaction = await input_device.read()
    
    # do something
    
    # To ack the message (remove from queue)
    await transaction.commit()
    # To nack the message (re-queue the message)
    await transaction.rollback()
```
#### Basic Get

```python
from aio_rabbitmq_utils import RabbitMQMultiConnectionBasicGetInputDeviceManager, RabbitMQInputBasicGetDevice


async def example():
    input_device_manager = RabbitMQMultiConnectionBasicGetInputDeviceManager(
        hosts=["the", "rabbit", "hosts", ", will", "connect", "to", "only", "one"],
        user="user",
        password="password",
        vhost="/",
        max_connections=10,
        max_channels=50,
    )
    await input_device_manager.connect()
    input_device: RabbitMQInputBasicGetDevice = await input_device_manager.get_device("some_queue_name")
    await input_device.connect()
    data, headers, transaction = await input_device.read()
    
    # do something
    
    # To ack the message (remove from queue)
    await transaction.commit()
    # To nack the message (re-queue the message)
    await transaction.rollback()
```

### Example for writer

```python
from io import BytesIO
from aio_rabbitmq_utils import RabbitMQOutputDeviceManager, RabbitMQOutputDevice


async def example():
    output_device_manager = RabbitMQOutputDeviceManager(
        hosts=["the", "rabbit", "hosts", ", will", "connect", "to", "only", "one"],
        user="user",
        password="password",
        vhost="/",
        exchange_name="",
    )
    await output_device_manager.connect()
    output_device: RabbitMQOutputDevice = await output_device_manager.get_device("some_routing_key")
    await output_device.connect()
    success = await output_device.send(
        BytesIO(b"Hi"),
        {"some": "headers"},
    )
    if success:
        print("Message sent")
    else:
        raise Exception("Failed to send the message")
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "aio-rabbitmq-utils",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "rabbitmq, pika, aio, async",
    "author": null,
    "author_email": "Omer Dagry <omerdagry@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/9e/86/cc4db92aef0da32559bf008980e9b6939e902899809fac5767333f770ab7/aio_rabbitmq_utils-1.0.8.tar.gz",
    "platform": null,
    "description": "# RabbitMQUtils\r\n\r\n### Example for reader\r\n#### Consumer\r\n\r\n```python\r\nfrom aio_rabbitmq_utils import RabbitMQConsumeInputDeviceManager, RabbitMQInputConsumeDevice\r\n\r\n\r\nasync def example():\r\n    input_device_manager = RabbitMQConsumeInputDeviceManager(\r\n        hosts=[\"the\", \"rabbit\", \"hosts\", \", will\", \"connect\", \"to\", \"only\", \"one\"],\r\n        user=\"user\",\r\n        password=\"password\",\r\n        vhost=\"/\",\r\n        prefetch_count=10,\r\n    )\r\n    await input_device_manager.connect()\r\n    input_device: RabbitMQInputConsumeDevice = await input_device_manager.get_device(\"some_queue_name\")\r\n    await input_device.connect()\r\n    data, headers, transaction = await input_device.read()\r\n    \r\n    # do something\r\n    \r\n    # To ack the message (remove from queue)\r\n    await transaction.commit()\r\n    # To nack the message (re-queue the message)\r\n    await transaction.rollback()\r\n```\r\n#### Basic Get\r\n\r\n```python\r\nfrom aio_rabbitmq_utils import RabbitMQMultiConnectionBasicGetInputDeviceManager, RabbitMQInputBasicGetDevice\r\n\r\n\r\nasync def example():\r\n    input_device_manager = RabbitMQMultiConnectionBasicGetInputDeviceManager(\r\n        hosts=[\"the\", \"rabbit\", \"hosts\", \", will\", \"connect\", \"to\", \"only\", \"one\"],\r\n        user=\"user\",\r\n        password=\"password\",\r\n        vhost=\"/\",\r\n        max_connections=10,\r\n        max_channels=50,\r\n    )\r\n    await input_device_manager.connect()\r\n    input_device: RabbitMQInputBasicGetDevice = await input_device_manager.get_device(\"some_queue_name\")\r\n    await input_device.connect()\r\n    data, headers, transaction = await input_device.read()\r\n    \r\n    # do something\r\n    \r\n    # To ack the message (remove from queue)\r\n    await transaction.commit()\r\n    # To nack the message (re-queue the message)\r\n    await transaction.rollback()\r\n```\r\n\r\n### Example for writer\r\n\r\n```python\r\nfrom io import BytesIO\r\nfrom aio_rabbitmq_utils import RabbitMQOutputDeviceManager, RabbitMQOutputDevice\r\n\r\n\r\nasync def example():\r\n    output_device_manager = RabbitMQOutputDeviceManager(\r\n        hosts=[\"the\", \"rabbit\", \"hosts\", \", will\", \"connect\", \"to\", \"only\", \"one\"],\r\n        user=\"user\",\r\n        password=\"password\",\r\n        vhost=\"/\",\r\n        exchange_name=\"\",\r\n    )\r\n    await output_device_manager.connect()\r\n    output_device: RabbitMQOutputDevice = await output_device_manager.get_device(\"some_routing_key\")\r\n    await output_device.connect()\r\n    success = await output_device.send(\r\n        BytesIO(b\"Hi\"),\r\n        {\"some\": \"headers\"},\r\n    )\r\n    if success:\r\n        print(\"Message sent\")\r\n    else:\r\n        raise Exception(\"Failed to send the message\")\r\n```\r\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2024 Omer Dagry  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "A package for async communication with RabbitMQ",
    "version": "1.0.8",
    "project_urls": {
        "Homepage": "https://github.com/Omer-Dagry/RabbitMQUtils",
        "Issues": "https://github.com/Omer-Dagry/RabbitMQUtils/issues"
    },
    "split_keywords": [
        "rabbitmq",
        " pika",
        " aio",
        " async"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ede627a47a2e862dee695f19283a92fca4a961360afcf38bd211b9c9827284c4",
                "md5": "1f82d910a806f986379e6e10c8b8f5bf",
                "sha256": "a60a715cf40e493ef5d8621aca49c9aa4bf38691e383bdab50dce828566ba2dd"
            },
            "downloads": -1,
            "filename": "aio_rabbitmq_utils-1.0.8-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "1f82d910a806f986379e6e10c8b8f5bf",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 12887,
            "upload_time": "2024-10-17T17:17:58",
            "upload_time_iso_8601": "2024-10-17T17:17:58.259987Z",
            "url": "https://files.pythonhosted.org/packages/ed/e6/27a47a2e862dee695f19283a92fca4a961360afcf38bd211b9c9827284c4/aio_rabbitmq_utils-1.0.8-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9e86cc4db92aef0da32559bf008980e9b6939e902899809fac5767333f770ab7",
                "md5": "459b2dc2af5ee1ef348b279bf8682759",
                "sha256": "8a2db61d3470b21ce3554e2484e20640ba47f487197700feaa9357846c671289"
            },
            "downloads": -1,
            "filename": "aio_rabbitmq_utils-1.0.8.tar.gz",
            "has_sig": false,
            "md5_digest": "459b2dc2af5ee1ef348b279bf8682759",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 8532,
            "upload_time": "2024-10-17T17:18:00",
            "upload_time_iso_8601": "2024-10-17T17:18:00.055979Z",
            "url": "https://files.pythonhosted.org/packages/9e/86/cc4db92aef0da32559bf008980e9b6939e902899809fac5767333f770ab7/aio_rabbitmq_utils-1.0.8.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-17 17:18:00",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Omer-Dagry",
    "github_project": "RabbitMQUtils",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "setuptools",
            "specs": [
                [
                    "==",
                    "75.*"
                ]
            ]
        },
        {
            "name": "aio-pika",
            "specs": [
                [
                    "==",
                    "9.*"
                ]
            ]
        },
        {
            "name": "no-exception",
            "specs": [
                [
                    "==",
                    "1.*"
                ]
            ]
        }
    ],
    "lcname": "aio-rabbitmq-utils"
}
        
Elapsed time: 4.09289s