A rubbish Kafka broker, for testing simple messaging
Project description
A rubbish Kafka broker, for testing simple messaging
Nafka implements just enough of the Kafka broker for simple producer/consumer code to talk to it for testing. It's designed to be convenient to launch, run some tests, and shut down again.
Usage
The package provides a pytest fixture nafka_broker. The broker is running
while the fixture is in use, and it has these attributes and methods:
nb.address: The broker address to connect to, a string like"127.0.0.1:32977"nb.topics(): Get a list of topic names for which at least 1 record exists.nb.records(topic, start_offset=0, limit=1000): Get a list of records in the given topic.nb.next_offset(topic): Get the offset for the next record to be added to the given topic.with nb.assert_produces(topic): Check that there are more records in the topic at the end of thewithblock than at the start. Usingwith ... as new_recs:also gives an iterable to inspect the new records.nb.add_record(topic, value, key=None, timestamp_ms=None): Add a record as if it was sent by a producer. The new record is sent to any waiting consumers.nb.consumer_offset(group, topic): Get the committed consumer group offset for the given group in the given topic.
The records are saved in a kafka.sqlite file in a per-test temp directory
managed by pytest - this can be useful for investigation.
Limitations
- Standalone single broker, no distributed architecture
- One partition per topic
- Not optimised for performance
- No log compaction: messages are all stored (until test cleanup removes the entire store)
- Listens only on localhost
- Many Kafka features are not implemented, only what we've needed for tests
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 nafka-0.1.tar.gz.
File metadata
- Download URL: nafka-0.1.tar.gz
- Upload date:
- Size: 10.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.32.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
42857e8adbf4b77b92734476fca69d4a6472a55d9d30de5095bd0118e786f18f
|
|
| MD5 |
8528cad126e09b07650c30d8110d8b13
|
|
| BLAKE2b-256 |
ba0bf4093ade2dfe8dd21353af028c156286d8305cfc89e75a046e7f5c471507
|
File details
Details for the file nafka-0.1-py2.py3-none-any.whl.
File metadata
- Download URL: nafka-0.1-py2.py3-none-any.whl
- Upload date:
- Size: 11.8 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.32.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2158e953a213df6fa30fbda9ba34552ee962fe22fd978c39fedbbe52412e334c
|
|
| MD5 |
1244dd48d16c0a37c507c0f09ed314c5
|
|
| BLAKE2b-256 |
420fa53925bd0bcdb01649fe8462f21338ea411959cc71166cf41587c6129ab0
|