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
Copy file name to clipboardExpand all lines: README.md
+97-22Lines changed: 97 additions & 22 deletions
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
-
# 🚧WIP🚧: Swift Kafka Client
1
+
# Swift Kafka Client
2
2
3
-
Swift Kafka Client 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`](https://github.com/confluentinc/librdkafka) C library.
3
+
The Swift Kafka Client library provides a convenient way to interact with [Apache Kafka](https://kafka.apache.org)by leveraging [Swift's new concurrency features](https://docs.swift.org/swift-book/LanguageGuide/Concurrency.html). This package wraps the native [`librdkafka`](https://github.com/confluentinc/librdkafka) library.
4
4
5
5
## Adding Kafka as a Dependency
6
6
@@ -32,12 +32,11 @@ Both the `KafkaProducer` and the `KafkaConsumer` implement the [`Service`](https
32
32
The `send(_:)` method of `KafkaProducer` returns a message-id that can later be used to identify the corresponding acknowledgement. Acknowledgements are received through the `events`[`AsyncSequence`](https://developer.apple.com/documentation/swift/asyncsequence). Each acknowledgement indicates that producing a message was successful or returns an error.
33
33
34
34
```swift
35
-
let broker = KafkaConfiguration.Broker(host: "localhost", port: 9092)
36
-
var config =KafkaProducerConfiguration()
37
-
config.bootstrapBrokerAddresses= [broker]
35
+
let brokerAddress = KafkaConfiguration.BrokerAddress(host: "localhost", port: 9092)
36
+
let configuration =KafkaProducerConfiguration(bootstrapBrokerAddresses: [brokerAddress])
38
37
39
38
let (producer, events) =try KafkaProducer.makeProducerWithEvents(
40
-
config: config,
39
+
configuration: configuration,
41
40
logger: logger
42
41
)
43
42
@@ -79,17 +78,17 @@ await withThrowingTaskGroup(of: Void.self) { group in
79
78
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).
@@ -156,15 +155,15 @@ await withThrowingTaskGroup(of: Void.self) { group in
156
155
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.
157
156
158
157
```swift
159
-
let broker = KafkaConfiguration.Broker(host: "localhost", port: 9092)
0 commit comments