An opinionated library for pub/sub over SQS and SNS
Project description
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>"))
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
tqp-0.5.1.tar.gz
(8.7 kB
view details)
Built Distribution
tqp-0.5.1-py3-none-any.whl
(10.5 kB
view details)
File details
Details for the file tqp-0.5.1.tar.gz
.
File metadata
- Download URL: tqp-0.5.1.tar.gz
- Upload date:
- Size: 8.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.8.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 187a0117cb5d6f0dd5386ca617386556665545480e4e7daec1f41210e3e20218 |
|
MD5 | bb5c6d535880ca53132e50710d7f0aa5 |
|
BLAKE2b-256 | a933a64749b84350b28763574918cfb781cb9ceb1dd1bb8578f55c503fb2a7a4 |
File details
Details for the file tqp-0.5.1-py3-none-any.whl
.
File metadata
- Download URL: tqp-0.5.1-py3-none-any.whl
- Upload date:
- Size: 10.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.8.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7f2432adaf111c96d69fc13dc105bac55bc8642f16e544007d9672dc5d8f9e8d |
|
MD5 | 7316742307e71fed1758ca81244a9034 |
|
BLAKE2b-256 | b28f514dd0ac004c972d594c0f97ba7ecca4dfd6467b7806b1493dc2e0230104 |