Razemax
✉️ Async communications using AWS SNS + SQS for Python services ✨
Documentation
In-Memory event manager
Show me the code
from razemax.event_manager import EventManager
class NorthKoreaThreatCreatedEvent:
def __init__(self, id, target):
self.id = id
self.target = target
def trump_subscriber(event: NorthKoreaThreatCreatedEvent):
print(f"North korea will attack us or {event.target}!")
EventManager.subscribe(trump_subscriber, NorthKoreaThreatCreatedEvent)
EventManager.trigger(NorthKoreaThreatCreatedEvent(0, "Mexico"))
Result:
North korea will attack us or Mexico!
Trigger subscribers from SQS
Preconditions
SQS queue has to be subscribed to SNS topic before running the consumer
Code
from razemax.consumers import MessageConsumer
from razemax.drivers import SQSDriver
from razemax.event_manager import EventManager
from razemax.publisher import SNSMessagePublisher
def kp_message_to_event(message):
# Highly recommended to use Marshmallow to validate
return NorthKoreaThreatCreatedEvent(message.body['id'], message.body['target_name'])
mapper = {
'KPThreatCreated': kp_message_to_event
}
aws_settings = {
'region_name': "",
'aws_access_key_id': "",
'aws_secret_access_key': "",
'endpoint_url': ""
}
queue_driver = SQSDriver.build("korea-threats-queue", aws_settings)
MessageConsumer(mapper, EventManager, queue_driver).process_message()
publisher = SNSMessagePublisher.build(aws_settings, 'korea-topic')
publisher.publish('KPThreatCreated', {'id': 21, 'target_name': 'Portugal'})
Result:
North korea will attack us or Portugal!
Installing (TODO)
pip install git@github.com/transporter
Running the tests
To run end to end tests do:
make unit-tests
make integration-tests
Authors
- Jairo Vadillo (@jairovadillo)
License
This project is licensed under the MIT License - see the LICENSE.md file for details
Metadata
Release files for razemax 0.0.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| razemax-0.0.8.tar.gz | 4.5 kB | Without provenance | Details for razemax-0.0.8.tar.gz |
Release files / razemax-0.0.8.tar.gz
| Download URL | razemax-0.0.8.tar.gz |
|---|---|
| Size | 4.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b5b8eb8cdb2257cf19e9baae176741ec14b67ab30712c13d7ed7ac7405b32656
|
|
BLAKE2b-256 checksum How to use checksums |
69494849e1ac79fa126cc761e5cf580446399d96ee25fd28eb4d77c0cdf4d4ef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.3
|
Security for razemax 0.0.8
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.