Skip to main content

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>"))

Logstash

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

Provides a TQP poller as an LogStash input plugin.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tqp-1.0.0.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

tqp-1.0.0-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file tqp-1.0.0.tar.gz.

File metadata

  • Download URL: tqp-1.0.0.tar.gz
  • Upload date:
  • Size: 9.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.18

File hashes

Hashes for tqp-1.0.0.tar.gz
Algorithm Hash digest
SHA256 f4d571a1be0a28fd24c6a5703334671c2c782ad135ef4d7856d48a5f439dce2b
MD5 40f07a5a8354164e37146dcd520d215b
BLAKE2b-256 d88d9afd5b95f8c2e9cda5f5b70c7bd66a2ac84b9856dc825779cad718d79212

See more details on using hashes here.

Provenance

File details

Details for the file tqp-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: tqp-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 10.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.18

File hashes

Hashes for tqp-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 211dfb71e735896de91a3bd290d124f9708566aa5340ec6b76f94c7549b70a8c
MD5 50633f18fc3e7990afe11f1bb49c4a83
BLAKE2b-256 0482ec5c14faba3c6d886c46726ed830f734dc5a2acd864bc605576718fd3823

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page