Skip to main content

SQS Callback decorator

Python decorator for registering message handlers from Simple Queue Service endpoints.

  • decorator register callbacks for specific queues
  • listen to iterate over all callbacks, read messages from queues and dispatch
  • post to quickly send data to a queue and obtain message ID

install

pip install bayis-sqs-callback

usage

import sqsfn

@sqsfn.sqs_queue_listener(sqs_queue_name="my-queue-name")
def my_example_queue_listener(data_from_queue):
  """process a queue item"""
  print("recieved data")
  return True


if __name__ == "__main__":
  asyncio.run(sqsfn.listen())

multiple queues

import sqsfn

@sqsfn.sqs_queue_listener(sqs_queue_name="queue-a")
def my_example_queue_listener(data_from_queue_a):
  print("received from queue a")
  sqsfn.post("queue-b", data_from_queue_a)
  return True

@sqsfn.sqs_queue_listener(sqs_queue_name="queue-b")
def my_example_queue_listener(data_from_queue_b):
  print("received from queue b")
  sqsfn.post("queue-c", data_from_queue_b)
  return True

@sqsfn.sqs_queue_listener(sqs_queue_name="queue-c")
def my_example_queue_listener(data_from_queue_c):
  print("received from queue c")
  sqsfn.post("queue-a", data_from_queue_c)
  return True

if __name__ == "__main__":
  asyncio.run(sqsfn.listen())

success and failure queues

the on_success and on_fail optional parameters accept a function which will be called on successful processing of the message or otherwise.

import sqsfn

@sqsfn.sqs_queue_listener(
    sqs_queue_name="my-queue-name",
    on_success=lambda x: sqsfn.post("my-success-queue", x),
    on_fail=lambda x: sqsfn.post("my-fail-queue", x)
)
def my_example_queue_listener(data_from_queue):
  """process a queue item"""
  print("recieved data")
  return True


if __name__ == "__main__":
  asyncio.run(sqsfn.listen())

Metadata

Release files for bayis-sqs-callback 0.0.4

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

Source distribution (sdist)

Source distribution for bayis-sqs-callback 0.0.4
File Size Uploaded
bayis-sqs-callback-0.0.4.tar.gz 5.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bayis-sqs-callback 0.0.4
File Interpreter ABI Platform
bayis_sqs_callback-0.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 11.4 kB

Release files / bayis-sqs-callback-0.0.4.tar.gz

Download URL bayis-sqs-callback-0.0.4.tar.gz
Size 5.5 kB
Tags Source
SHA-256 checksum
How to use checksums
c0d19fa5dccbd29c78c52a92b36427c4533699275fd7b200bca8ea498ef9c91a
BLAKE2b-256 checksum
How to use checksums
6b6c62adf6ef6ef73b8eb40aa2fe6dd865df8cb3dd3b1dc2a152e7bb4e6f3e00
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.2

Release files / bayis_sqs_callback-0.0.4-py3-none-any.whl

Download URL bayis_sqs_callback-0.0.4-py3-none-any.whl
Size 5.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a7061e2f2dd0a86f7830120b5278cc9da7d901cd76551150e5cf525546c4221e
BLAKE2b-256 checksum
How to use checksums
eea578a3140a7c79a5df302f4e913815af585c4839971d29a898f7d03db02562
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.2

Release history Release notifications | RSS feed

This release

0.0.4 This release

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

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