tqp


Nametqp JSON
Version 1.0.0 PyPI version JSON
download
home_pagehttps://github.com/4Catalyzer/tqp
SummaryAn opinionated library for pub/sub over SQS and SNS
upload_time2024-03-05 15:29:04
maintainer
docs_urlNone
authorGiacomo Tagliabue
requires_python>=3.6
licenseMIT
keywords pub sub pubsub flask
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage No coveralls.
            # TQP

An opinionated library for pub/sub over SQS and SNS

## Topic

To publish on a topic:

```py
topic = Topic('widgets--created')
topic.publish({'id': '123456'})
```

## Topic Queue Poller

To read from the topic:

```py
poller = TopicQueuePoller('my_poller')

@poller.handler('widgets--created')
def process_created_widget(item):
    widget_id = item['id']
    print(f'Widget {widget_id} was created')

poller.start()
```

### S3 notifications

It is also possible to poll for s3 object notifications

```py
@poller.s3_handler('my-bucket-name')
def process_file_created(msg):
    print(msg)
    # {
    #     'event_name': 'ObjectCreated:Put',
    #     'bucket_name': 'bespin-dev-consular21d51f71-11lpitfowdylc',
    #     'object': {
    #         'key': 'genome.fasta',
    #         'size': 124,
    #         'eTag': '5d9d04cd0b9d3b314d9bd622da06ab74',
    #         'sequencer': '005FAD55883A198E97'
    #     },
    # }
```

### Flask

A Flask binding is also provided:

```py
poller = FlaskTopicQueuePoller('my_poller', app=flask_app)
```

When using the Flask poller, you can also specify how to format the logs:

```py
# the argument (optional) is a function that takes the message payload as input and return a message identifier
poller.set_log_formatter(lambda payload: payload["message"].get("id", "<NO ID>"))
```

### Logstash

https://github.com/jquense/logstash-input-tqp

Provides a TQP poller as an LogStash input plugin.


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/4Catalyzer/tqp",
    "name": "tqp",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "pub sub pubsub flask",
    "author": "Giacomo Tagliabue",
    "author_email": "giacomo@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/d8/8d/9afd5b95f8c2e9cda5f5b70c7bd66a2ac84b9856dc825779cad718d79212/tqp-1.0.0.tar.gz",
    "platform": null,
    "description": "# TQP\n\nAn opinionated library for pub/sub over SQS and SNS\n\n## Topic\n\nTo publish on a topic:\n\n```py\ntopic = Topic('widgets--created')\ntopic.publish({'id': '123456'})\n```\n\n## Topic Queue Poller\n\nTo read from the topic:\n\n```py\npoller = TopicQueuePoller('my_poller')\n\n@poller.handler('widgets--created')\ndef process_created_widget(item):\n    widget_id = item['id']\n    print(f'Widget {widget_id} was created')\n\npoller.start()\n```\n\n### S3 notifications\n\nIt is also possible to poll for s3 object notifications\n\n```py\n@poller.s3_handler('my-bucket-name')\ndef process_file_created(msg):\n    print(msg)\n    # {\n    #     'event_name': 'ObjectCreated:Put',\n    #     'bucket_name': 'bespin-dev-consular21d51f71-11lpitfowdylc',\n    #     'object': {\n    #         'key': 'genome.fasta',\n    #         'size': 124,\n    #         'eTag': '5d9d04cd0b9d3b314d9bd622da06ab74',\n    #         'sequencer': '005FAD55883A198E97'\n    #     },\n    # }\n```\n\n### Flask\n\nA Flask binding is also provided:\n\n```py\npoller = FlaskTopicQueuePoller('my_poller', app=flask_app)\n```\n\nWhen using the Flask poller, you can also specify how to format the logs:\n\n```py\n# the argument (optional) is a function that takes the message payload as input and return a message identifier\npoller.set_log_formatter(lambda payload: payload[\"message\"].get(\"id\", \"<NO ID>\"))\n```\n\n### Logstash\n\nhttps://github.com/jquense/logstash-input-tqp\n\nProvides a TQP poller as an LogStash input plugin.\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "An opinionated library for pub/sub over SQS and SNS",
    "version": "1.0.0",
    "project_urls": {
        "Homepage": "https://github.com/4Catalyzer/tqp"
    },
    "split_keywords": [
        "pub",
        "sub",
        "pubsub",
        "flask"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0482ec5c14faba3c6d886c46726ed830f734dc5a2acd864bc605576718fd3823",
                "md5": "50633f18fc3e7990afe11f1bb49c4a83",
                "sha256": "211dfb71e735896de91a3bd290d124f9708566aa5340ec6b76f94c7549b70a8c"
            },
            "downloads": -1,
            "filename": "tqp-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "50633f18fc3e7990afe11f1bb49c4a83",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 10506,
            "upload_time": "2024-03-05T15:29:02",
            "upload_time_iso_8601": "2024-03-05T15:29:02.669199Z",
            "url": "https://files.pythonhosted.org/packages/04/82/ec5c14faba3c6d886c46726ed830f734dc5a2acd864bc605576718fd3823/tqp-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d88d9afd5b95f8c2e9cda5f5b70c7bd66a2ac84b9856dc825779cad718d79212",
                "md5": "40f07a5a8354164e37146dcd520d215b",
                "sha256": "f4d571a1be0a28fd24c6a5703334671c2c782ad135ef4d7856d48a5f439dce2b"
            },
            "downloads": -1,
            "filename": "tqp-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "40f07a5a8354164e37146dcd520d215b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 9529,
            "upload_time": "2024-03-05T15:29:04",
            "upload_time_iso_8601": "2024-03-05T15:29:04.422682Z",
            "url": "https://files.pythonhosted.org/packages/d8/8d/9afd5b95f8c2e9cda5f5b70c7bd66a2ac84b9856dc825779cad718d79212/tqp-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-05 15:29:04",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "4Catalyzer",
    "github_project": "tqp",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": false,
    "tox": true,
    "lcname": "tqp"
}
        
Elapsed time: 0.85865s