Skip to main content

Build data streaming pipelines using faststan

Project description

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)

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

faststan-0.1.2.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

faststan-0.1.2-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file faststan-0.1.2.tar.gz.

File metadata

  • Download URL: faststan-0.1.2.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.10 CPython/3.7.5 Linux/4.4.0-17763-Microsoft

File hashes

Hashes for faststan-0.1.2.tar.gz
Algorithm Hash digest
SHA256 cc488ca31b9376cecd24cf0bdd76060a7f60a2fb593c9677bcf5810bda431d66
MD5 ac14d0c6ad5611e8e708034b412d3694
BLAKE2b-256 77527e08c421831a4fa530327fb6c297bd8bd42b9e390337ce74822530cc3e0f

See more details on using hashes here.

File details

Details for the file faststan-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: faststan-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.10 CPython/3.7.5 Linux/4.4.0-17763-Microsoft

File hashes

Hashes for faststan-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9caa2f90e848351b95bad5ad8784e44e1b173cce5206f42314f300cb28e94b76
MD5 1b71f4bd16bfac634af1696a9d59a769
BLAKE2b-256 f6e9ceac1fccdec1dec19f9a5e0e35c77f4ec8068ed620caa0da11088673142a

See more details on using hashes here.

Supported by

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