Snapstream
Snapstream provides a data-flow model to simplify development of stateful streaming applications.
Installation
pip install snapstream
Usage
We snap iterables to user functions, and process them in parallel when we call stream:
We pass the callable print to print out the return value. Multiple iterables and sinks can be passed.
from snapstream import snap, stream
@snap(range(5), sink=[print])
def handler(msg):
yield f'Hello {msg}'
stream()
Hello 0
Hello 1
Hello 2
Hello 3
Hello 4
To try it out for yourself, spin up a local kafka broker with docker-compose.yml, using localhost:29091 to connect:
docker compose up broker -d
Use the cli tool to inspect Topic/Cache:
snapstream topic emoji --offset -2
>>> timestamp: 2023-04-28T17:31:51.775000+00:00
>>> offset: 0
>>> key:
🏆
Features
snapstream.snap: bind streams (iterables) and sinks (callables) to user defined handler functionssnapstream.stream: start streamingsnapstream.Topic: consume from (iterable), and produce to (callable) kafka using confluent-kafkasnapstream.Cache: store data to disk using rocksdictsnapstream.Conf: set global kafka configuration (can be overridden per topic)snapstream.codecs.AvroCodec: serialize and deserialize avro messagessnapstream.codecs.JsonCodec: serialize and deserialize json messages
Metadata
Release files for snapstream 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| snapstream-1.0.0.tar.gz | 15.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| snapstream-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 31.1 kB
Release files / snapstream-1.0.0.tar.gz
| Download URL | snapstream-1.0.0.tar.gz |
|---|---|
| Size | 15.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3d0ba0794a26ce33d402ea3470dc196ce4ced1ed72e3a18b6157b122b9d78dad
|
|
BLAKE2b-256 checksum How to use checksums |
c967acd181918a0bc94ca852e29d2d09966e5424f5bbb2b183147cd413947ea0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.4.2 CPython/3.10.14 Linux/6.5.0-1016-azure
|
Release files / snapstream-1.0.0-py3-none-any.whl
| Download URL | snapstream-1.0.0-py3-none-any.whl |
|---|---|
| Size | 16.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f5323d0c7f5c94a459f7dfed460514b5e823784b65155f003b289b7c27603358
|
|
BLAKE2b-256 checksum How to use checksums |
740f9bd2576285f13a92facdf08a8f03a9b6b2ff4fcf0abd40d319a14f3ccc45
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.4.2 CPython/3.10.14 Linux/6.5.0-1016-azure
|