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)
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:
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.