Confluent kafka Wrapper to publish messages to Kafka broker with a defined Structure
Project description
Repo Setup
Setup aws cli with DE-prod account credentials
export CODEARTIFACT_AUTH_TOKEN=`aws codeartifact get-authorization-token --domain simpl --domain-owner 950779425701 --region ap-south-1 --query authorizationToken --output text`
poetry config repositories.simpl_utils https://aws:$CODEARTIFACT_AUTH_TOKEN@simpl-950779425701.d.codeartifact.ap-south-1.amazonaws.com/pypi/pypi-store/
poetry config repositories.simpl_kafka_event_publisher https://aws:$CODEARTIFACT_AUTH_TOKEN@simpl-950779425701.d.codeartifact.ap-south-1.amazonaws.com/pypi/pypi-store/
Kafka Config
Below are the available options available for configuring kafka producer behavior
| Attribute | Kafka Config Mapping | Default Value |
|---|---|---|
bootstrap_servers |
bootstrap.servers |
Required |
client_id |
client.id |
"" |
linger_ms |
linger.ms |
5ms |
batch_size |
batch.size |
16384 |
delivery_timeout_ms |
delivery.timeout.ms |
120000 |
batch_num_messages |
batch.num.messages |
1000 |
compression_type |
compression.type |
none |
acks |
acks |
all |
connections_max_idle_ms |
connections.max.idle.ms |
540000 |
queue_buffering_max_messages |
queue.buffering.max.messages |
100000 |
queue_buffering_max_kbytes |
queue.buffering.max.kbytes |
100 |
Usage
- Define a KafkaConfig Object
config = KafkaConfig(
bootstrap_servers="localhost:29092",
linger_ms=1,
batch_size=1,
queue_buffering_max_messages=1,
batch_num_messages=1
)
- Create a KafkaEventPublisher Object
producer = KafkaEventProducer(config)
- Create an event object schema by inheriting from
BaseEventModel
class CustomEventModel(BaseEventModel):
phone_number: str
user_id: str
...
event = CustomEventModel(phone_number="1234567890", user_id="123")
- Publish messages to kafka using above producer, providing topic name and event
producer.publish("some_topic", event)
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file simpl_kafka_wrapper-0.2.3.tar.gz.
File metadata
- Download URL: simpl_kafka_wrapper-0.2.3.tar.gz
- Upload date:
- Size: 5.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.10.9 Darwin/22.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bc432d85095410b3eba0194c71181c40991809660baafffe784fc04e4d91b022
|
|
| MD5 |
6abb8fb54470056a01f35a8aaded4f3f
|
|
| BLAKE2b-256 |
cdd855976b675203fef40cde8772a9fc50927c7f37e56c5152712b22522df9f8
|
File details
Details for the file simpl_kafka_wrapper-0.2.3-py3-none-any.whl.
File metadata
- Download URL: simpl_kafka_wrapper-0.2.3-py3-none-any.whl
- Upload date:
- Size: 8.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.10.9 Darwin/22.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fbb33d3fe8f783b469ab960b905dfe83e2caa4383178d9e38e0bd26fe154a664
|
|
| MD5 |
912a9e634fd5d10f0cc9c5a530e80693
|
|
| BLAKE2b-256 |
b54b6ea212595ce86f4f57f25b1c179e6b9ab142b56824ee7471732a6578cb02
|