Skip to main content

AWS SQS item processing callback

Project description

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

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

bayis-sqs-callback-0.0.4.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bayis_sqs_callback-0.0.4-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file bayis-sqs-callback-0.0.4.tar.gz.

File metadata

  • Download URL: bayis-sqs-callback-0.0.4.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.2

File hashes

Hashes for bayis-sqs-callback-0.0.4.tar.gz
Algorithm Hash digest
SHA256 c0d19fa5dccbd29c78c52a92b36427c4533699275fd7b200bca8ea498ef9c91a
MD5 3483afac5f6b333dcffe9b0a9f0d11c2
BLAKE2b-256 6b6c62adf6ef6ef73b8eb40aa2fe6dd865df8cb3dd3b1dc2a152e7bb4e6f3e00

See more details on using hashes here.

File details

Details for the file bayis_sqs_callback-0.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for bayis_sqs_callback-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 a7061e2f2dd0a86f7830120b5278cc9da7d901cd76551150e5cf525546c4221e
MD5 360363796e021a7d9af5e079e7d6b5b6
BLAKE2b-256 eea578a3140a7c79a5df302f4e913815af585c4839971d29a898f7d03db02562

See more details on using hashes here.

Supported by

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