Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

KAFKA-CLIENT-NEW

Примеры использования:

Через manager

import json
import logging

from kafka_client import (
    DefaultBatchKafkaManager, 
    DefaultBatchProducer, 
    DefaultBatchConsumer,
)
from kafka_client.handler import EmptyHandler

logging.basicConfig(level=logging.INFO)


if __name__ == '__main__':
    batch_size = 10
    consumer_settings = {
        'bootstrap_servers': '...',
        'value_deserializer': lambda v: json.loads(v.decode('utf-8')),
        'key_deserializer': lambda k: k.decode('utf-8'),
        'client_id': '...',
        'group_id': '...',
        'enable_auto_commit': False,
        'auto_offset_reset': 'earliest'
    }
    consumer = DefaultBatchConsumer(
        topic='...',
        batch_size=batch_size,
        consumer_settings=consumer_settings
    )
    
    producer_settings = {
        'bootstrap_servers': '...',
        'key_serializer': str.encode,
        'value_serializer': lambda v: json.dumps(v).encode('utf-8'),
    }
    producer = DefaultBatchProducer(topic='...', producer_settings=producer_settings)
    
    manager = DefaultBatchKafkaManager(consumer, producer)
    manager.set_handler(handler=EmptyHandler())
    manager.run()

Через функцию run

задаем переменные окружения

  • BATCH_SIZE [optional] - размер батча
  • BOOTSTRAP_SERVERS - брокеры кафки
  • INPUT_TOPIC - входной топик
  • OUTPUT_TOPIC - выходной топик
  • CLIENT_ID [optional] - имя приложения, как то отсылается в кафку
  • GROUP_ID - kafka consumer group

Запускаем python:

import logging

from kafka_client import run
from kafka_client.handler import EmptyHandler

logging.basicConfig(level=logging.INFO)


if __name__ == '__main__':
    run(handler=EmptyHandler())

Metadata

Release files for kafka-client-new 0.4.dev2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kafka-client-new 0.4.dev2
File Size Uploaded Provenance Actions
kafka_client_new-0.4.dev2.tar.gz 4.4 kB Without provenance Details for kafka_client_new-0.4.dev2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for kafka-client-new 0.4.dev2
File Interpreter ABI Platform Actions
kafka_client_new-0.4.dev2-py3-none-any.whl Python 3 none any Details for kafka_client_new-0.4.dev2-py3-none-any.whl

Total release size: 11.1 kB

Release files / kafka_client_new-0.4.dev2.tar.gz

Download URL kafka_client_new-0.4.dev2.tar.gz
Size 4.4 kB
Tags Source
SHA-256 checksum
How to use checksums
488f0c9d9290199a45b061545d6522b8235328bf563a20e262fbe935fd94aeb0
BLAKE2b-256 checksum
How to use checksums
4712e01647bbc5d82e8f6974521052c05b5107ff75f414917d83009626b220a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.0 CPython/3.9.0 Darwin/22.3.0

Release files / kafka_client_new-0.4.dev2-py3-none-any.whl

Download URL kafka_client_new-0.4.dev2-py3-none-any.whl
Size 6.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
af3765eec46dc15d0fb73ad836b15324c09613f11acc9356e90985d4eac3aaa9
BLAKE2b-256 checksum
How to use checksums
74fcc91d5fc6620b6eff49ba3b236f3ac2752767dda1de684475d9bcfcab81c0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.0 CPython/3.9.0 Darwin/22.3.0

Security for kafka-client-new 0.4.dev2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page