FastSTAN
Easily deploy NATS Streaming subscribers using Python.
Features
- Define subscribers using sync and async python functions
- Automatic data parsing and validation using type annotations and pydantic
- Support custom validation using any function
- Allow several subscribers on same channel
- Support all subscription configuration available in stan.py
- Healthcheck available using HTTP GET request to monitor the applications
- (TODO) Metrics available using HTTP GET requests to monitor subsriptions status
- All of FastAPI features
Quick start
- Install the package from pypi:
pip install faststan
- Create your first subscriber:
from faststan.faststan import FastSTAN
app = FastSTAN()
@app.subscribe("demo")
def on_event(message: str):
print(f"INFO :: Received new message: {message}")
- Start your subscriber:
uvicorn app:app
Advanced features
Using error callbacks
from faststan.faststan import FastSTAN
app = FastSTAN()
def handle_error(error):
print("ERROR: {error}")
@app.subscribe("demo", error_cb=handle_error)
def on_event(message: str):
print(f"INFO :: Received new message: {message}")
Using pydantic models
You can use pydantic models in order to automatically parse incoming messages:
from pydantic import BaseModel
from faststan.faststan import FastSTAN
class Event(BaseModel):
timestamp: int
temperature: float
humidity: float
app = FastSTAN()
@app.subscribe("event")
def on_event(event):
msg = f"INFO :: {event.timestamp} :: Temperature: {event.temperature} | Humidity: {event.humidity}"
print(msg)
Metadata
Release files for faststan 0.1.2
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 | |
|---|---|---|---|---|
| faststan-0.1.2.tar.gz | 5.0 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| faststan-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.8 kB
Release files / faststan-0.1.2.tar.gz
| Download URL | faststan-0.1.2.tar.gz |
|---|---|
| Size | 5.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cc488ca31b9376cecd24cf0bdd76060a7f60a2fb593c9677bcf5810bda431d66
|
|
BLAKE2b-256 checksum How to use checksums |
77527e08c421831a4fa530327fb6c297bd8bd42b9e390337ce74822530cc3e0f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.10 CPython/3.7.5 Linux/4.4.0-17763-Microsoft
|
Release files / faststan-0.1.2-py3-none-any.whl
| Download URL | faststan-0.1.2-py3-none-any.whl |
|---|---|
| Size | 5.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9caa2f90e848351b95bad5ad8784e44e1b173cce5206f42314f300cb28e94b76
|
|
BLAKE2b-256 checksum How to use checksums |
f6e9ceac1fccdec1dec19f9a5e0e35c77f4ec8068ed620caa0da11088673142a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.10 CPython/3.7.5 Linux/4.4.0-17763-Microsoft
|
Security for faststan 0.1.2
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.