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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
feda7d105a054c0d579d7c5d2d41806fed17eeaa1aa75ec5ea8db326b337a69d
|
|
| MD5 |
561c84178cd3775b81fbcdf1c0cd4e25
|
|
| BLAKE2b-256 |
9f0a5b7a2452dae68fab9a63e3ccc7740bad5f07cc1b0110cf5d67f279b3f9ec
|
Provenance
The following attestation bundles were made for spanreed-0.2.tar.gz:
Publisher:
publish.yml on mbachry/spanreed
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spanreed-0.2.tar.gz -
Subject digest:
feda7d105a054c0d579d7c5d2d41806fed17eeaa1aa75ec5ea8db326b337a69d - Sigstore transparency entry: 218362080
- Sigstore integration time:
-
Permalink:
mbachry/spanreed@520cc17b7213c2c43fc7060a7df2e5237411f078 -
Branch / Tag:
refs/tags/v0.2 - Owner: https://github.com/mbachry
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@520cc17b7213c2c43fc7060a7df2e5237411f078 -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
961a712254753a56e928db0d44c7ed2548118011638a3e8e60088e451de2379c
|
|
| MD5 |
68b50f9b349695286ddbfd666c561a84
|
|
| BLAKE2b-256 |
636648e5bc6272e8c2130f5ac3eea19efb79330a716deb7e80439ef3b58b4e05
|
Provenance
The following attestation bundles were made for spanreed-0.2-py3-none-any.whl:
Publisher:
publish.yml on mbachry/spanreed
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spanreed-0.2-py3-none-any.whl -
Subject digest:
961a712254753a56e928db0d44c7ed2548118011638a3e8e60088e451de2379c - Sigstore transparency entry: 218362090
- Sigstore integration time:
-
Permalink:
mbachry/spanreed@520cc17b7213c2c43fc7060a7df2e5237411f078 -
Branch / Tag:
refs/tags/v0.2 - Owner: https://github.com/mbachry
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@520cc17b7213c2c43fc7060a7df2e5237411f078 -
Trigger Event:
push
-
Statement type: