Skip to main content

TQP

An opinionated library for pub/sub over SQS and SNS

Topic

To publish on a topic:

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

Topic Queue Poller

To read from the topic:

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

@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:

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

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

# 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.

Release files for tqp 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tqp 1.0.0
File Size Uploaded
tqp-1.0.0.tar.gz 9.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tqp 1.0.0
File Interpreter ABI Platform
tqp-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 20.0 kB

Release files / tqp-1.0.0.tar.gz

Download URL tqp-1.0.0.tar.gz
Size 9.5 kB
Tags Source
SHA-256 checksum
How to use checksums
f4d571a1be0a28fd24c6a5703334671c2c782ad135ef4d7856d48a5f439dce2b
BLAKE2b-256 checksum
How to use checksums
d88d9afd5b95f8c2e9cda5f5b70c7bd66a2ac84b9856dc825779cad718d79212
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.9.18

Release files / tqp-1.0.0-py3-none-any.whl

Download URL tqp-1.0.0-py3-none-any.whl
Size 10.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
211dfb71e735896de91a3bd290d124f9708566aa5340ec6b76f94c7549b70a8c
BLAKE2b-256 checksum
How to use checksums
0482ec5c14faba3c6d886c46726ed830f734dc5a2acd864bc605576718fd3823
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.9.18
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page