You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Update README
Motivation:
This PR closes issue #28.
Modifications:
* add instructions on how to build librdkafka from source
* add documentation for public interface
* Linux: Change librdkafka installation
Modifications:
* changed Docker image Ubuntu release to Jammy
* use the Confluence repository for installing librdkafka on Linux
systems
Copy file name to clipboardExpand all lines: README.md
+119-9Lines changed: 119 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,10 @@
1
-
# 🚧WIP🚧: swift-kafka-gsoc
1
+
# 🚧WIP🚧: SwiftKafka
2
2
3
-
This package is currently under development as part of the Google Summer of Code 2022.
4
-
It aims to provide a library to interact with Apache Kafka.
3
+
SwiftKafka is a Swift Package in development that provides a convenient way to communicate with [Apache Kafka](https://kafka.apache.org) servers. The main goal was to create an API that leverages [Swift's new concurrency features](https://docs.swift.org/swift-book/LanguageGuide/Concurrency.html). Under the hood, this package uses the [`librdkafka`](github.com/edenhill/librdkafka) C library.
5
4
6
-
## Installing Dependencies
5
+
## Getting Started
6
+
7
+
### Installing Dependencies
7
8
8
9
Please make sure to have the [`librdkafka`](https://github.com/edenhill/librdkafka) library installed before building.
9
10
@@ -15,11 +16,15 @@ brew install librdkafka
15
16
16
17
#### Linux
17
18
19
+
The default `apt-get` package for the library is outdated. Therefore, we recommend installing [`librdkafka`](https://github.com/edenhill/librdkafka) from the [official Confluence package repository](https://docs.confluent.io/platform/current/installation/installing_cp/deb-ubuntu.html#get-the-software).
As part of developing for Linux, we also provide a Docker environment for this package. It only contains a proof-of-concept program but will be expanded in the future.
55
+
### Docker
53
56
54
-
To run the proof-of-concept program, use:
57
+
We also provide a Docker environment for this package. This will automatically start a local Kafka server and run the package tests.
55
58
56
59
```bash
57
60
docker-compose -f docker/docker-compose.yaml run swift-kafka-gsoc
58
61
```
62
+
63
+
## Overview
64
+
65
+
### Producer API
66
+
67
+
The `sendAsync(_:)` method of `KafkaProducer` returns a message-id that can later be used to identify the corresponding acknowledgement. Acknowledgements are received through the `acknowledgements`[`AsyncSequence`](https://developer.apple.com/documentation/swift/asyncsequence). Each acknowledgement indicates that producing a message was successful or returns an error.
forawait acknowledgement in producer.acknowledgements {
86
+
// Check if acknowledgement belongs to the sent message
87
+
}
88
+
89
+
// Required
90
+
await producer.shutdownGracefully()
91
+
```
92
+
93
+
### Consumer API
94
+
95
+
After initializing the `KafkaConsumer` with a topic-partition pair to read from, messages can be consumed using the `messages`[`AsyncSequence`](https://developer.apple.com/documentation/swift/asyncsequence).
By default, the `KafkaConsumer` automatically commits message offsets after receiving the corresponding message. However, we allow users to disable this setting and commit message offsets manually.
0 commit comments