typedkafka 0.3.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,263 @@
1
+ Metadata-Version: 2.4
2
+ Name: typedkafka
3
+ Version: 0.3.1
4
+ Summary: A well-documented, fully type-hinted Kafka client for Python
5
+ Project-URL: Homepage, https://github.com/Jgprog117/typedkafka
6
+ Project-URL: Documentation, https://github.com/Jgprog117/typedkafka#readme
7
+ Project-URL: Repository, https://github.com/Jgprog117/typedkafka
8
+ Project-URL: Issues, https://github.com/Jgprog117/typedkafka/issues
9
+ Author: typedkafka contributors
10
+ License: MIT
11
+ License-File: LICENSE
12
+ Keywords: confluent-kafka,consumer,documentation,event-driven,kafka,messaging,producer,streaming,type-hints,typed
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.9
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
24
+ Classifier: Topic :: System :: Distributed Computing
25
+ Classifier: Typing :: Typed
26
+ Requires-Python: >=3.9
27
+ Requires-Dist: confluent-kafka>=2.0.0
28
+ Provides-Extra: avro
29
+ Requires-Dist: confluent-kafka[avro]>=2.0.0; extra == 'avro'
30
+ Provides-Extra: dev
31
+ Requires-Dist: mypy>=1.0.0; extra == 'dev'
32
+ Requires-Dist: pytest-asyncio>=0.21.0; extra == 'dev'
33
+ Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
34
+ Requires-Dist: pytest>=7.0.0; extra == 'dev'
35
+ Requires-Dist: ruff>=0.1.0; extra == 'dev'
36
+ Description-Content-Type: text/markdown
37
+
38
+ # typedkafka
39
+
40
+ A well-documented, fully type-hinted Kafka client for Python.
41
+
42
+ [![Python Version](https://img.shields.io/pypi/pyversions/typedkafka)](https://pypi.org/project/typedkafka/)
43
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
44
+
45
+ ## Overview
46
+
47
+ typedkafka provides a modern Python interface to Apache Kafka with comprehensive documentation, full type hints, and developer-friendly features. Built on confluent-kafka for performance and reliability.
48
+
49
+ **Key Features:**
50
+ - Full type hints and comprehensive docstrings
51
+ - JSON, string, and bytes message helpers
52
+ - Transaction support with context managers
53
+ - Async producer and consumer (`asyncio`)
54
+ - Retry utilities with exponential backoff
55
+ - Pluggable serializer framework (JSON, String, Avro/Schema Registry)
56
+ - Testing utilities (MockProducer/MockConsumer)
57
+ - Type-safe configuration builders with validation
58
+ - Admin client for topic management
59
+
60
+ ## Installation
61
+
62
+ ```bash
63
+ pip install typedkafka
64
+
65
+ # With Avro/Schema Registry support
66
+ pip install typedkafka[avro]
67
+ ```
68
+
69
+ Requires Python 3.9+.
70
+
71
+ ## Quick Start
72
+
73
+ ### Producer
74
+
75
+ ```python
76
+ from typedkafka import KafkaProducer
77
+
78
+ with KafkaProducer({"bootstrap.servers": "localhost:9092"}) as producer:
79
+ producer.send("my-topic", b"Hello, Kafka!")
80
+ producer.send_json("events", {"user_id": 123, "action": "click"})
81
+ producer.send_string("logs", "Application started")
82
+ producer.flush()
83
+ ```
84
+
85
+ ### Consumer
86
+
87
+ ```python
88
+ from typedkafka import KafkaConsumer
89
+
90
+ config = {
91
+ "bootstrap.servers": "localhost:9092",
92
+ "group.id": "my-consumer-group",
93
+ "auto.offset.reset": "earliest"
94
+ }
95
+
96
+ with KafkaConsumer(config) as consumer:
97
+ consumer.subscribe(["my-topic"])
98
+ for msg in consumer:
99
+ data = msg.value_as_json()
100
+ print(f"Received: {data}")
101
+ consumer.commit(msg)
102
+ ```
103
+
104
+ ### Transactions
105
+
106
+ ```python
107
+ from typedkafka import KafkaProducer
108
+
109
+ producer = KafkaProducer({
110
+ "bootstrap.servers": "localhost:9092",
111
+ "transactional.id": "my-txn-id",
112
+ })
113
+ producer.init_transactions()
114
+
115
+ with producer.transaction():
116
+ producer.send("topic", b"msg1")
117
+ producer.send("topic", b"msg2")
118
+ # Commits on success, aborts on exception
119
+ ```
120
+
121
+ ### Async
122
+
123
+ ```python
124
+ from typedkafka.aio import AsyncKafkaProducer, AsyncKafkaConsumer
125
+
126
+ async with AsyncKafkaProducer({"bootstrap.servers": "localhost:9092"}) as producer:
127
+ await producer.send("topic", b"async message")
128
+ await producer.send_json("events", {"id": 1})
129
+ await producer.flush()
130
+
131
+ async with AsyncKafkaConsumer(config) as consumer:
132
+ consumer.subscribe(["topic"])
133
+ async for msg in consumer:
134
+ process(msg)
135
+ ```
136
+
137
+ ### Retry
138
+
139
+ ```python
140
+ from typedkafka.retry import retry, RetryPolicy
141
+
142
+ @retry(max_attempts=3, backoff_base=1.0)
143
+ def send_with_retry(producer, data):
144
+ producer.send_json("events", data)
145
+ producer.flush()
146
+
147
+ # Or use RetryPolicy programmatically
148
+ policy = RetryPolicy(max_attempts=5, backoff_base=0.5)
149
+ policy.execute(producer.send, "topic", b"value")
150
+ ```
151
+
152
+ ### Serializers
153
+
154
+ ```python
155
+ from typedkafka.serializers import JsonSerializer, AvroSerializer
156
+
157
+ json_ser = JsonSerializer()
158
+ data = json_ser.serialize("topic", {"user_id": 123})
159
+
160
+ # Avro with Schema Registry (requires typedkafka[avro])
161
+ avro_ser = AvroSerializer("http://localhost:8081", schema_str)
162
+ data = avro_ser.serialize("users", {"id": 123, "name": "Alice"})
163
+ ```
164
+
165
+ ### Batch Send
166
+
167
+ ```python
168
+ producer.send_batch("events", [
169
+ (b"event1", b"key1"),
170
+ (b"event2", b"key2"),
171
+ (b"event3", None),
172
+ ])
173
+ producer.flush()
174
+ ```
175
+
176
+ ## Testing Utilities
177
+
178
+ Mock implementations for testing without a running Kafka broker:
179
+
180
+ ```python
181
+ from typedkafka.testing import MockProducer, MockConsumer
182
+
183
+ def test_my_producer():
184
+ producer = MockProducer()
185
+ my_function(producer)
186
+ assert len(producer.messages["events"]) == 1
187
+
188
+ def test_my_consumer():
189
+ consumer = MockConsumer()
190
+ consumer.add_json_message("events", {"user_id": 123})
191
+ result = process_messages(consumer)
192
+ assert result is not None
193
+
194
+ def test_transactions():
195
+ producer = MockProducer()
196
+ producer.init_transactions()
197
+ with producer.transaction():
198
+ producer.send("topic", b"transactional msg")
199
+ assert len(producer.messages["topic"]) == 1
200
+ ```
201
+
202
+ ## Type-Safe Configuration
203
+
204
+ Fluent builders with validation and IDE autocomplete:
205
+
206
+ ```python
207
+ from typedkafka import ProducerConfig, ConsumerConfig, KafkaProducer
208
+
209
+ config = (ProducerConfig()
210
+ .bootstrap_servers("localhost:9092")
211
+ .acks("all")
212
+ .compression("gzip")
213
+ .linger_ms(10)
214
+ .build())
215
+
216
+ producer = KafkaProducer(config)
217
+ ```
218
+
219
+ Invalid values raise `ValueError` immediately:
220
+
221
+ ```python
222
+ ProducerConfig().acks("invalid") # ValueError
223
+ ProducerConfig().compression("brotli") # ValueError
224
+ ```
225
+
226
+ ## Development
227
+
228
+ ```bash
229
+ git clone https://github.com/Jgprog117/typedkafka.git
230
+ cd typedkafka
231
+ pip install -e ".[dev]"
232
+ pytest
233
+ ruff check .
234
+ mypy src
235
+ ```
236
+
237
+ ## License
238
+
239
+ MIT License - see LICENSE file for details.
240
+
241
+ ## Changelog
242
+
243
+ ### 0.3.0
244
+
245
+ - Transaction support: `init_transactions()`, `begin/commit/abort_transaction()`, `transaction()` context manager
246
+ - Async producer and consumer (`typedkafka.aio`)
247
+ - Retry utilities: `@retry` decorator and `RetryPolicy` class
248
+ - Pluggable serializers: `Serializer`/`Deserializer` ABCs, JSON, String, and Avro implementations
249
+ - Batch send: `send_batch()` on producer
250
+ - Consumer rebalance callbacks: `on_assign`, `on_revoke`, `on_lost` on `subscribe()`
251
+ - Configurable iterator poll timeout via `poll_timeout` attribute
252
+ - Config validation: early `ValueError` on invalid `acks`, `compression`, `auto_offset_reset`, `linger_ms`, `batch_size`
253
+ - Expanded test suite (120 tests)
254
+
255
+ ### 0.2.0
256
+
257
+ - Testing utilities (MockProducer, MockConsumer)
258
+ - Type-safe configuration builders (ProducerConfig, ConsumerConfig)
259
+ - Admin client wrapper for topic management
260
+
261
+ ### 0.1.0
262
+
263
+ - Initial release with KafkaProducer, KafkaConsumer, full type hints, context manager support
@@ -0,0 +1,14 @@
1
+ typedkafka/__init__.py,sha256=1yUm_Fec2g2i_kDKZX_lfv2WmoruuSTmBcHIO1YYGRE,1292
2
+ typedkafka/admin.py,sha256=d5cgmT-ckFpKHqfOBsQX3cTnaopfEhVO9K8NbMJnM_Y,10383
3
+ typedkafka/aio.py,sha256=xWrVerdVFehjwA7kEVgvljOb_eXbuW9jG0dsE3TTR2A,10813
4
+ typedkafka/config.py,sha256=Ixbw0y7o9QuXmxWNbbmthIMNfdZskPKWJC0jvx2sqUY,12001
5
+ typedkafka/consumer.py,sha256=wU81T2e9rTvtA30_Dq-NEglkQ7uxxal6NCAVp2M4_QI,14303
6
+ typedkafka/exceptions.py,sha256=mzqgEqSua_OoTPOquAnWzZOiDG3Q02Qr1qpfybRNcRQ,3961
7
+ typedkafka/producer.py,sha256=y3Gg5TfCKW8sSi8j_vJcDrgDi1kkSph39lL4EIlIqq4,17431
8
+ typedkafka/retry.py,sha256=17EtRb6Dl5K66XXwTQW1uUHxyOVcWFXVHJDtyQuUWHI,5252
9
+ typedkafka/serializers.py,sha256=yanNrmdqsJAsxj98IYLQh-XYVWIcsekeuEigJ-5W_3Y,9084
10
+ typedkafka/testing.py,sha256=bATq1oWqo7V0ER4p2b25eKxfH_C7Uz_CXJyww-typOs,16302
11
+ typedkafka-0.3.1.dist-info/METADATA,sha256=JAiqpEo4Qw_WnG03lFHUR7b25upe0skxMFRD_bfjL-Y,7570
12
+ typedkafka-0.3.1.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
13
+ typedkafka-0.3.1.dist-info/licenses/LICENSE,sha256=9jW1j0gPHGTxWKjNlGVvG3eXzyYUJxyFKZjrTMYGe1A,1080
14
+ typedkafka-0.3.1.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.28.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 typedkafka contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.