summaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
Diffstat (limited to 'README.md')
-rw-r--r--README.md23
1 files changed, 23 insertions, 0 deletions
diff --git a/README.md b/README.md
index 9f02412..1e22054 100644
--- a/README.md
+++ b/README.md
@@ -172,3 +172,26 @@ req = ProduceRequest(topic, 1, messages)
kafka.send_message_set(req)
kafka.close()
```
+
+## Use Kafka like a FIFO queue
+
+Simple API: `get`, `put`, `close`.
+
+```python
+kafka = KafkaClient("localhost", 9092)
+q = KafkaQueue(kafka, "my-topic", [0,1])
+q.put("first")
+q.put("second")
+q.get() # first
+q.get() # second
+q.close()
+kafka.close()
+```
+
+Since the producer and consumers are backed by actual `multiprocessing.Queue`, you can
+do blocking or non-blocking puts and gets.
+
+```python
+q.put("first", block=False)
+q.get(block=True, timeout=10)
+```