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

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-0.5.0.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: tqp-0.5.0.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.51.0 CPython/3.8.0

File hashes

Hashes for tqp-0.5.0.tar.gz
Algorithm Hash digest
SHA256 11050dd72e33c04e28c591236ccee14d861e0df1a0ebfc2d11dcadff53cbd87d
MD5 710bcaedcdeb6bf057cd294bb501aa2c
BLAKE2b-256 890d5628a3258b4902fcba3ccdc159cb005435a1313bf365658d7a775b1c5623

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tqp-0.5.0-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.51.0 CPython/3.8.0

File hashes

Hashes for tqp-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 344a854b10516b77ca8df50af113f853a1b48e73820dd0341413a31e9c0a97d0
MD5 a34a6d8af9b778603fe015de57ea38f7
BLAKE2b-256 f3ace2301bc9a169bdce17b745ab1f2781cf84e00fa6ceb6d755fbae88ff2817

See more details on using hashes here.

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