Streamline your Kafka data processing, this tool aims to standardize streaming data from multiple Kafka clusters. With a pub-sub approach, multiple functions can easily subscribe to incoming messages, serialization can be specified per topic, and data is automatically processed by data sink functions.
Project description
Snapstream
A tiny data-flow model with a user-friendly interface that provides sensible defaults for Kafka integration, message serialization/deserialization, and data caching.
In response to a challenge of performing a "merge-as-of", "nearby join", or "merge by key distance" operation on multiple kafka streams while reading topics from separate kafka clusters, this package was born.
No actual stream or external database is required, cached data is persisted to disk using rocksdb, applications using snapstream are more inclined to be; self-contained, easy to extend, less complex, easy to test using regular iterables:
Installation
pip install snapstream
Usage
In the example below, snap
decorates the handle
function, binding the iterable range(5)
to it:
from snapstream import snap, stream
r = range(5)
@snap(r, sink=[print])
def handler(msg):
return f'Hello {msg}'
stream()
Hello 0
Hello 1
Hello 2
Hello 3
Hello 4
Features
snapstream.Topic
: an iterable/callable to consume and produce (default: confluent-kafka)snapstream.Cache
: a callable/dict to persist data (default: rocksdict)snapstream.Conf
: a singleton object, can be used to store common kafka configurationssnapstream.snap
: a function to bind streams (iterables) and sinks (callables) to user defined handler functionssnapstream.stream
: a function to start the streams
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
Hashes for snapstream-0.0.0.dev3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f860ae40889a88688565008820189a731b732c2bca05b8bae00c3b499530e588 |
|
MD5 | f7c265500d52b24651ae43fae98040d0 |
|
BLAKE2b-256 | 2c685670e3dbb05ad7022cc0f10045dbcbeb0ce156b0a94e0648222f390c46eb |