Skip to main content

No project description provided

Project description

spanreed

Message bus and task manager using redis streams.

Install

pip install spanreed

Configuration

Django configuration is supported. Alternatively, create a settings module and point SPANREED_SETTINGS_MOUDULE env variable to it.

Set SPANREED_REDIS_URL to your redis dsn.

Set SPANREED_MODELS to a list of import strings with your pydantic classes (see below), eg. SPANREED_MODELS = ('app.models.User', 'app.models.Permission').

Set SPANREED_PUBLISHER to your app name.

Set SPANREED_QUEUE to your environment name (eg. staging, prod).

Make sure all modules with tasks are imported at startup.

Message bus usage

Messages are broadcast to all listening apps. Use them to synchronize app state and implement "event sourcing" flows.

Create a message pydantic class by inheriting from spanreed.models.BaseMessage:

from spanreed.models import BaseMessage, Metadata

class UserCreated(BaseMessage):
    user_id: str

    def handle(self):
        print('got message', self)


user = UserCreated(user_id='id')
user.publish()

publish sends a message to the bus, handle is called by a daemon when a message is received.

Run the daemon with spanreed-consumer --queue-type message or manage.py spanreed_worker --queue-type message if using Django.

Task manager usage

Tasks are delivered only once inside a single app. Use them as celery replacement.

Create a task:

from spanreed import task

@task
def frobnicate_user(user_id):
    frobnicate(user_id)

frobnicate_user.dispatch('uid')

dispatch sends a task to the bus, which will be invoked by a daemon.

Run the daemon with spanreed-consumer --queue-type task or manage.py spanreed_worker --queue-type task if using Django.

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

spanreed-0.2.tar.gz (18.6 kB view details)

Uploaded Source

Built Distribution

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

spanreed-0.2-py3-none-any.whl (16.8 kB view details)

Uploaded Python 3

File details

Details for the file spanreed-0.2.tar.gz.

File metadata

  • Download URL: spanreed-0.2.tar.gz
  • Upload date:
  • Size: 18.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for spanreed-0.2.tar.gz
Algorithm Hash digest
SHA256 feda7d105a054c0d579d7c5d2d41806fed17eeaa1aa75ec5ea8db326b337a69d
MD5 561c84178cd3775b81fbcdf1c0cd4e25
BLAKE2b-256 9f0a5b7a2452dae68fab9a63e3ccc7740bad5f07cc1b0110cf5d67f279b3f9ec

See more details on using hashes here.

Provenance

The following attestation bundles were made for spanreed-0.2.tar.gz:

Publisher: publish.yml on mbachry/spanreed

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file spanreed-0.2-py3-none-any.whl.

File metadata

  • Download URL: spanreed-0.2-py3-none-any.whl
  • Upload date:
  • Size: 16.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for spanreed-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 961a712254753a56e928db0d44c7ed2548118011638a3e8e60088e451de2379c
MD5 68b50f9b349695286ddbfd666c561a84
BLAKE2b-256 636648e5bc6272e8c2130f5ac3eea19efb79330a716deb7e80439ef3b58b4e05

See more details on using hashes here.

Provenance

The following attestation bundles were made for spanreed-0.2-py3-none-any.whl:

Publisher: publish.yml on mbachry/spanreed

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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