Skip to main content

Kafka for the Pico ecosystem: @kafka_consumer methods and @kafka_producer clients over aiokafka.

Project description

pico-kafka

PyPI Ask DeepWiki License: MIT CI (tox matrix) codecov Quality Gate Status Duplicated Lines (%) Maintainability Rating PyPI Downloads Docs Interactive Lab

Kafka for the pico ecosystem: @kafka_consumer methods and declarative @kafka_producer clients over aiokafka.

Installation

pip install pico-kafka

Quick start

kafka:
  bootstrap_servers: kafka.internal:9092
  group_id: myapp

Consume — a component method per topic, JSON value decoded for you:

from pico_ioc import component
from pico_kafka import kafka_consumer

@component
class OrderProjection:
    @kafka_consumer("orders")
    async def on_order(self, message: dict):
        ...

    @kafka_consumer("orders", group_id="analytics")   # independent fan-out
    def on_order_analytics(self, message: dict):
        ...

Produce — stubs, like a pico-httpx client:

from pico_kafka import kafka_producer, produce

@kafka_producer
class OrderEvents:
    @produce("orders")
    def order_created(self, message): ...

Semantics:

  • Consumers and producers run on a dedicated background loop — works in sync scripts, FastAPI apps and workers alike, no lifespan wiring.
  • Each record resolves its component through the container (prototype scope = fresh instance per record).
  • A record whose handler raises is logged and skipped — offsets advance, a poison record cannot stall the partition.
  • Sync produce stubs block until the broker acks; async stubs await it. Everything stops with the container.

Documentation

Full documentation: https://dperezcabrera.github.io/pico-kafka/

AI Coding Skills

Install Claude Code or OpenAI Codex skills for AI-assisted development with pico-kafka:

curl -sL https://raw.githubusercontent.com/dperezcabrera/pico-skills/main/install.sh | bash

The pico-conventions skill teaches the assistant this module's API surface and invariants; /add-component and /add-tests scaffold components and tests that use it.

License

MIT

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

pico_kafka-0.1.5.tar.gz (26.4 kB view details)

Uploaded Source

Built Distribution

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

pico_kafka-0.1.5-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file pico_kafka-0.1.5.tar.gz.

File metadata

  • Download URL: pico_kafka-0.1.5.tar.gz
  • Upload date:
  • Size: 26.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pico_kafka-0.1.5.tar.gz
Algorithm Hash digest
SHA256 67a23e36b908e5903a529c9170ec2125ef31f733190d54f157346f1f685f5f16
MD5 c205b5c551ae2167ffcde4371f9e19c9
BLAKE2b-256 79c713d064d6939b8f4be719c4bb35637c3e6819fed80df29df67ae6e18a2a2d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pico_kafka-0.1.5.tar.gz:

Publisher: publish-to-pypi.yml on dperezcabrera/pico-kafka

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pico_kafka-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: pico_kafka-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pico_kafka-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 912176684fadbba8a02573e7c6d5c165a95ca2c415914459bc56a9033bef9a5a
MD5 a527215c2ac9d8d8721eec70e43d54f1
BLAKE2b-256 a7c8864ecf7492c91be4a9f0b76b2a669c7f0a0ac91949eb8acfbd2f969fbfb4

See more details on using hashes here.

Provenance

The following attestation bundles were made for pico_kafka-0.1.5-py3-none-any.whl:

Publisher: publish-to-pypi.yml on dperezcabrera/pico-kafka

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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