Skip to main content

High-performance Python client for wynd data ingest.

Project description

wynd-dataingest

High-performance Python client for wynd data ingest.

It is built for services that want:

  • HTTP connection reuse through httpx
  • explicit sync and async clients with NDJSON as the default mode
  • retries with exponential backoff and jitter
  • optional gzip compression based on raw payload size
  • publish-ready packaging for pip install

Install

pip install wynd-dataingest

Quick Start

Sync client

from wynd_dataingest import CompressionOptions, WyndDataIngestClient

client = WyndDataIngestClient(
    url="http://127.0.0.1:8686/events",
    connections=16,
    table_name="orders",
    table_operation="insert",
    compression=CompressionOptions(gzip=True),
    headers={
        "authorization": "Basic my-token",
    },
)

result = client.send(
    [
        {"service": "api", "level": "info", "message": "order accepted"},
        {"service": "api", "message": "batch item 1"},
        {"service": "api", "message": "batch item 2"},
    ]
)

print(result.status_code)
client.close()

ndjson is the default mode, so send() expects a sequence and emits newline-delimited JSON unless you set mode="json" or mode="text".

Async client

from wynd_dataingest import AsyncWyndDataIngestClient, CompressionOptions


async def ingest() -> None:
    client = AsyncWyndDataIngestClient(
        url="http://127.0.0.1:8686/events",
        compression=CompressionOptions(gzip=True),
    )
    try:
        result = await client.send(
            [
                {"service": "api", "message": "batch item 1"},
                {"service": "api", "message": "batch item 2"},
            ]
        )

        print(result.status_code)
    finally:
        await client.aclose()

API

WyndDataIngestClient(...)

Supported constructor options:

  • url: full endpoint URL
  • mode: "json" | "ndjson" | "text"; defaults to "ndjson"
  • connections: max pooled HTTP connections; defaults to 16
  • table_name: base table name for the table-name header
  • table_operation: "insert" | "new" | "update" | "delete"; defaults to "insert" when table_name is set
  • headers: default request headers
  • timeout_ms: per-request timeout; defaults to 30000
  • user_agent: override the default user agent
  • retry: RetryOptions
  • compression: CompressionOptions

Sending data

The client exposes:

  • send(payload, options=None)
  • close()
  • AsyncWyndDataIngestClient.send(payload, options=None)
  • AsyncWyndDataIngestClient.aclose()

send() behaves by mode:

  • mode="ndjson": payload must be a sequence and is serialized as newline-delimited JSON
  • mode="json": payload is serialized with json.dumps
  • mode="text": payload must be a string or sequence of strings
  • bytes or bytearray payloads are sent as-is and can override content type with SendOptions(content_type=...)

Table Routing Header

When table_name is configured, the client automatically adds a table-name header:

  • table_operation="insert" or "new" -> table-name: <table_name>
  • table_operation="update" -> table-name: <table_name>-updates
  • table_operation="delete" -> table-name: <table_name>-deletes

Compression

Enable gzip with built-in defaults:

from wynd_dataingest import CompressionOptions, WyndDataIngestClient

client = WyndDataIngestClient(
    url="http://127.0.0.1:8686/events",
    compression=CompressionOptions(gzip=True),
)

That uses the default gzip threshold of 100KB raw bytes.

Or customize it:

from wynd_dataingest import CompressionOptions, GzipCompressionOptions, WyndDataIngestClient

client = WyndDataIngestClient(
    url="http://127.0.0.1:8686/events",
    compression=CompressionOptions(
        gzip=GzipCompressionOptions(min_bytes=4096, level=6)
    ),
)

Publish To PyPI

Build locally:

python3 -m pip install --upgrade build
python3 -m build

Upload to PyPI:

python3 -m pip install --upgrade twine
python3 -m twine upload dist/*

Then users can install it with:

pip install wynd-dataingest

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

wynd_dataingest-1.0.1.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

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

wynd_dataingest-1.0.1-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file wynd_dataingest-1.0.1.tar.gz.

File metadata

  • Download URL: wynd_dataingest-1.0.1.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for wynd_dataingest-1.0.1.tar.gz
Algorithm Hash digest
SHA256 17184be1309aacf62899f2ad52128e8f27204f9c5ca0af0343b8a0a5920a2098
MD5 623a15cf09bd9a8edad76fbc1ec6613d
BLAKE2b-256 498c6d7e9a376e64d44e6b2ac07823f0e951a83f49f0a1e79eac11d769cf7804

See more details on using hashes here.

File details

Details for the file wynd_dataingest-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for wynd_dataingest-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ce0e7354b25c9b18ac6fc2a2c8fe2f283049d1694159174dc6564da52e9256ca
MD5 a8a87565f987b525972c35dad9692e5c
BLAKE2b-256 61bf860afbaa46394eb39d5e075aee37feff69b90fee3124e65c2530dc2cdd34

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