Skip to main content

A Pythonic client library for streaming data with ZebraStream.

Project description

zebrastream-io

Python IO interface for ZebraStream data streaming services.

Disclaimer:
The code in this package is considered pre-production quality. APIs and functionality may change without notice. Use with caution in production environments.

Features

  • File-like synchronous interface for ZebraStream data streams
  • Async interface (internal, subject to change)
  • Easily extensible for other IO interfaces

Installation

pip install zebrastream-io

Usage

Synchronous file-like interface

The synchronous interface provides a familiar, file-like API for reading from and writing to ZebraStream data streams. This design allows you to interact with remote streams using standard Python file IO, making integration with existing codebases straightforward. The goal is to offer a simple and reliable way to handle streaming data without requiring knowledge of asynchronous programming or custom protocols.

Producer

import zebrastream.io.file as zsfile

with zsfile.open(mode="w", stream_path="/my-stream", access_token=token) as f:
    f.write("Hello!")
    f.flush() # force send buffer
    f.write("This is ZebraStream")

Consumer

import zebrastream.io.file as zsfile

with zsfile.open(mode="r", stream_path="/my-stream", access_token=token) as f:
    for line in f:
        print(line, end="")

Async interface (internal)

Async interface for performing network operations using the asyncio event loop.

This interface is currently non-public and subject to change, as it is under active development. The primary goal is to provide an internal, robust reference implementation for ZebraStream, leveraging Python's async/await syntax. At present, the implementation exclusively supports execution within the asyncio event loop, as it relies on the httpio library — the only request library currently offering reliable, full-duplex communication required for complete ZebraStream protocol support.

Future plans include stabilizing the API and exposing standard async streaming interfaces such as asyncio StreamReader/StreamWriter.

Producer

from zebrastream.io._core import AsyncWriter
import asyncio

async def main():
    async with AsyncWriter(stream_path="/my-stream", access_token=token) as writer:
        await writer.write(b"Hello!")
        await writer.flush()
        await writer.write("This is ZebraStream")

asyncio.run(main())

Consumer

from zebrastream.io._core import AsyncReader
import asyncio

async def main():
    async with AsyncReader(stream_path="/my-stream", access_token=token) as reader:
        while data := await reader.read_variable_block(4096):
            print(data.decode(), end="")

asyncio.run(main())

Documentation

See ZebraStream documentation for more details.

License

MIT License. See LICENSE for details.

See also

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

zebrastream_io-0.3.0.tar.gz (17.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

zebrastream_io-0.3.0-py3-none-any.whl (18.6 kB view details)

Uploaded Python 3

File details

Details for the file zebrastream_io-0.3.0.tar.gz.

File metadata

  • Download URL: zebrastream_io-0.3.0.tar.gz
  • Upload date:
  • Size: 17.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.1 CPython/3.13.1 Linux/6.11.0-1018-azure

File hashes

Hashes for zebrastream_io-0.3.0.tar.gz
Algorithm Hash digest
SHA256 70b1debe329a5446c40df29715511d1d83e3512a61314c86b7bb3e5b109e079a
MD5 f57ac61d384832ea2421bda2dbdbab9f
BLAKE2b-256 22799a8b619d79c5b92b3226e89aa252ece4e10012baf09d326d57b8b47db057

See more details on using hashes here.

File details

Details for the file zebrastream_io-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: zebrastream_io-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 18.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.1 CPython/3.13.1 Linux/6.11.0-1018-azure

File hashes

Hashes for zebrastream_io-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2b8f240b1b94a99563e0b0c6e9a78ceada9ca0dcda16d28bfcc7c85a90ec399d
MD5 4ec9c23d6129273552a5e962fa8ab6ef
BLAKE2b-256 9e7f17e512be5f8b74f20da5dcf2b72f118f5bf61ad6b54587ab78a3d5573298

See more details on using hashes here.

Supported by

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