Skip to content

Commit 1173b07

Browse files
Rename public Config types to Configuration (#65)
* Rename *Config types to *Configuration Modifications: * `KafkaConsumerConfig` -> `KafkaConsumerConfiguration` * `KafkaProducerConfig` -> `KafkaProducerConfiguration` * `KafkaTopicConfig` -> `KafkaTopicConfiguration` * * update `soundness.sh` to support new Configuration filenames
1 parent 840242c commit 1173b07

File tree

10 files changed

+37
-37
lines changed

10 files changed

+37
-37
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ SwiftKafka is a Swift Package in development that provides a convenient way to c
99
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.
1010

1111
```swift
12-
let config = KafkaProducerConfig(bootstrapServers: ["localhost:9092"])
12+
let config = KafkaProducerConfiguration(bootstrapServers: ["localhost:9092"])
1313

1414
let (producer, acknowledgements) = try await KafkaProducer.makeProducerWithAcknowledgements(
1515
config: config,
@@ -47,7 +47,7 @@ await withThrowingTaskGroup(of: Void.self) { group in
4747
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).
4848

4949
```swift
50-
let config = KafkaConsumerConfig(
50+
let config = KafkaConsumerConfiguration(
5151
consumptionStrategy: .partition(
5252
topic: "topic-name",
5353
partition: KafkaPartition(rawValue: 0)
@@ -75,7 +75,7 @@ for await messageResult in consumer.messages {
7575
SwiftKafka also allows users to subscribe to an array of topics as part of a consumer group.
7676

7777
```swift
78-
let config = KafkaConsumerConfig(
78+
let config = KafkaConsumerConfiguration(
7979
consumptionStrategy: .group(groupID: "example-group", topics: ["topic-name"]),
8080
bootstrapServers: ["localhost:9092"]
8181
)
@@ -100,7 +100,7 @@ for await messageResult in consumer.messages {
100100
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.
101101

102102
```swift
103-
let config = KafkaConsumerConfig(
103+
let config = KafkaConsumerConfiguration(
104104
consumptionStrategy: .group(groupID: "example-group", topics: ["topic-name"]),
105105
enableAutoCommit: false,
106106
bootstrapServers: ["localhost:9092"]

Sources/SwiftKafka/Configuration/KafkaConsumerConfig.swift renamed to Sources/SwiftKafka/Configuration/KafkaConsumerConfiguration.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import Crdkafka
1616
import struct Foundation.UUID
1717

18-
public struct KafkaConsumerConfig: Hashable, Equatable {
18+
public struct KafkaConsumerConfiguration: Hashable, Equatable {
1919
// MARK: - SwiftKafka-specific Config properties
2020

2121
/// The backpressure strategy to be used for message consumption.

Sources/SwiftKafka/Configuration/KafkaProducerConfig.swift renamed to Sources/SwiftKafka/Configuration/KafkaProducerConfiguration.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
//
1313
//===----------------------------------------------------------------------===//
1414

15-
public struct KafkaProducerConfig: Hashable, Equatable {
15+
public struct KafkaProducerConfiguration: Hashable, Equatable {
1616
var dictionary: [String: String] = [:]
1717

1818
// MARK: - Producer-specific Config Properties

Sources/SwiftKafka/Configuration/KafkaTopicConfig.swift renamed to Sources/SwiftKafka/Configuration/KafkaTopicConfiguration.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
//===----------------------------------------------------------------------===//
1414

1515
/// Used to configure new topics created by the ``KafkaProducer``.
16-
public struct KafkaTopicConfig: Hashable, Equatable {
16+
public struct KafkaTopicConfiguration: Hashable, Equatable {
1717
var dictionary: [String: String] = [:]
1818

1919
/// This field indicates the number of acknowledgements the leader broker must receive from ISR brokers before responding to the request: 0=Broker does not send any response/ack to client, -1 or all=Broker will block until message is committed by all in sync replicas (ISRs). If there are less than min.insync.replicas (broker configuration) in the ISR set the produce request will fail.

Sources/SwiftKafka/KafkaConsumer.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public struct ConsumerMessagesAsyncSequence: AsyncSequence {
5858
/// Receive messages from the Kafka cluster.
5959
public final class KafkaConsumer {
6060
/// The configuration object of the consumer client.
61-
private var config: KafkaConsumerConfig
61+
private var config: KafkaConsumerConfiguration
6262
/// A logger.
6363
private let logger: Logger
6464
/// Used for handling the connection to the Kafka cluster.
@@ -85,11 +85,11 @@ public final class KafkaConsumer {
8585
/// Initialize a new ``KafkaConsumer``.
8686
/// To listen to incoming messages, please subscribe to a list of topics using ``subscribe(topics:)``
8787
/// or assign the consumer to a particular topic + partition pair using ``assign(topic:partition:offset:)``.
88-
/// - Parameter config: The ``KafkaConsumerConfig`` for configuring the ``KafkaConsumer``.
88+
/// - Parameter config: The ``KafkaConsumerConfiguration`` for configuring the ``KafkaConsumer``.
8989
/// - Parameter logger: A logger.
9090
/// - Throws: A ``KafkaError`` if the initialization failed.
9191
public init(
92-
config: KafkaConsumerConfig,
92+
config: KafkaConsumerConfiguration,
9393
logger: Logger
9494
) throws {
9595
self.config = config

Sources/SwiftKafka/KafkaProducer.swift

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public struct KafkaMessageAcknowledgements: AsyncSequence {
3838

3939
/// Send messages to the Kafka cluster.
4040
/// Please make sure to explicitly call ``shutdownGracefully(timeout:)`` when the ``KafkaProducer`` is not used anymore.
41-
/// - Note: When messages get published to a non-existent topic, a new topic is created using the ``KafkaTopicConfig``
41+
/// - Note: When messages get published to a non-existent topic, a new topic is created using the ``KafkaTopicConfiguration``
4242
/// configuration object (only works if server has `auto.create.topics.enable` property set).
4343
public actor KafkaProducer {
4444
/// States that the ``KafkaProducer`` can have.
@@ -58,8 +58,8 @@ public actor KafkaProducer {
5858
/// Counter that is used to assign each message a unique ID.
5959
/// Every time a new message is sent to the Kafka cluster, the counter is increased by one.
6060
private var messageIDCounter: UInt = 0
61-
/// The ``TopicConfig`` used for newly created topics.
62-
private let topicConfig: KafkaTopicConfig
61+
/// The ``TopicConfiguration`` used for newly created topics.
62+
private let topicConfig: KafkaTopicConfiguration
6363
/// A logger.
6464
private let logger: Logger
6565
/// Dictionary containing all topic names with their respective `rd_kafka_topic_t` pointer.
@@ -70,13 +70,13 @@ public actor KafkaProducer {
7070

7171
// Private initializer, use factory methods to create KafkaProducer
7272
/// Initialize a new ``KafkaProducer``.
73-
/// - Parameter config: The ``KafkaProducerConfig`` for configuring the ``KafkaProducer``.
74-
/// - Parameter topicConfig: The ``KafkaTopicConfig`` used for newly created topics.
73+
/// - Parameter config: The ``KafkaProducerConfiguration`` for configuring the ``KafkaProducer``.
74+
/// - Parameter topicConfig: The ``KafkaTopicConfiguration`` used for newly created topics.
7575
/// - Parameter logger: A logger.
7676
/// - Throws: A ``KafkaError`` if initializing the producer failed.
7777
private init(
7878
client: KafkaClient,
79-
topicConfig: KafkaTopicConfig,
79+
topicConfig: KafkaTopicConfiguration,
8080
logger: Logger
8181
) async throws {
8282
self.client = client
@@ -90,14 +90,14 @@ public actor KafkaProducer {
9090
///
9191
/// This factory method creates a producer without message acknowledgements.
9292
///
93-
/// - Parameter configuration: The ``KafkaProducerConfig`` for configuring the ``KafkaProducer``.
94-
/// - Parameter topicConfiguration: The ``KafkaTopicConfig`` used for newly created topics.
93+
/// - Parameter configuration: The ``KafkaProducerConfiguration`` for configuring the ``KafkaProducer``.
94+
/// - Parameter topicConfiguration: The ``KafkaTopicConfiguration`` used for newly created topics.
9595
/// - Parameter logger: A logger.
9696
/// - Returns: The newly created ``KafkaProducer``.
9797
/// - Throws: A ``KafkaError`` if initializing the producer failed.
9898
public static func makeProducer(
99-
config: KafkaProducerConfig = KafkaProducerConfig(),
100-
topicConfig: KafkaTopicConfig = KafkaTopicConfig(),
99+
config: KafkaProducerConfiguration = KafkaProducerConfiguration(),
100+
topicConfig: KafkaTopicConfiguration = KafkaTopicConfiguration(),
101101
logger: Logger
102102
) async throws -> KafkaProducer {
103103
let client = try RDKafka.createClient(
@@ -124,15 +124,15 @@ public actor KafkaProducer {
124124
///
125125
/// - Important: When the asynchronous sequence is deinited the producer will be shutdown.
126126
///
127-
/// - Parameter config: The ``KafkaProducerConfig`` for configuring the ``KafkaProducer``.
128-
/// - Parameter topicConfig: The ``KafkaTopicConfig`` used for newly created topics.
127+
/// - Parameter config: The ``KafkaProducerConfiguration`` for configuring the ``KafkaProducer``.
128+
/// - Parameter topicConfig: The ``KafkaTopicConfiguration`` used for newly created topics.
129129
/// - Parameter logger: A logger.
130130
/// - Returns: A tuple containing the created ``KafkaProducer`` and the ``KafkaMessageAcknowledgements``
131131
/// `AsyncSequence` used for receiving message acknowledgements.
132132
/// - Throws: A ``KafkaError`` if initializing the producer failed.
133133
public static func makeProducerWithAcknowledgements(
134-
config: KafkaProducerConfig = KafkaProducerConfig(),
135-
topicConfig: KafkaTopicConfig = KafkaTopicConfig(),
134+
config: KafkaProducerConfiguration = KafkaProducerConfiguration(),
135+
topicConfig: KafkaTopicConfiguration = KafkaTopicConfiguration(),
136136
logger: Logger
137137
) async throws -> (KafkaProducer, KafkaMessageAcknowledgements) {
138138
var streamContinuation: AsyncStream<Result<KafkaAcknowledgedMessage, KafkaAcknowledgedMessageError>>.Continuation?

Sources/SwiftKafka/RDKafka/RDKafkaTopicConfig.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ import Crdkafka
1717
/// A collection of helper functions wrapping common `rd_kafka_topic_conf_*` functions in Swift.
1818
struct RDKafkaTopicConfig {
1919
/// Create a new `rd_kafka_topic_conf_t` object in memory and initialize it with the given configuration properties.
20-
/// - Parameter topicConfig: The ``KafkaTopicConfig`` used to initialize the `rd_kafka_topic_conf_t` object.
20+
/// - Parameter topicConfig: The ``KafkaTopicConfiguration`` used to initialize the `rd_kafka_topic_conf_t` object.
2121
/// - Returns: An `OpaquePointer` pointing to the newly created `rd_kafka_topic_conf_t` object in memory.
2222
/// - Throws: A ``KafkaError`` if setting a config value failed.
23-
static func createFrom(topicConfig: KafkaTopicConfig) throws -> OpaquePointer {
23+
static func createFrom(topicConfig: KafkaTopicConfiguration) throws -> OpaquePointer {
2424
let configPointer: OpaquePointer = rd_kafka_topic_conf_new()
2525
try topicConfig.dictionary.forEach { key, value in
2626
try Self.set(configPointer: configPointer, key: key, value: value)

Tests/IntegrationTests/SwiftKafkaTests.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,18 @@ final class SwiftKafkaTests: XCTestCase {
3434
let kafkaHost = ProcessInfo.processInfo.environment["KAFKA_HOST"] ?? "localhost"
3535
let kafkaPort = ProcessInfo.processInfo.environment["KAFKA_PORT"] ?? "9092"
3636
var bootstrapServer: String!
37-
var producerConfig: KafkaProducerConfig!
37+
var producerConfig: KafkaProducerConfiguration!
3838
var uniqueTestTopic: String!
3939

4040
override func setUpWithError() throws {
4141
self.bootstrapServer = "\(self.kafkaHost):\(self.kafkaPort)"
4242

43-
self.producerConfig = KafkaProducerConfig(
43+
self.producerConfig = KafkaProducerConfiguration(
4444
bootstrapServers: [self.bootstrapServer],
4545
brokerAddressFamily: .v4
4646
)
4747

48-
let basicConfig = KafkaConsumerConfig(
48+
let basicConfig = KafkaConsumerConfiguration(
4949
consumptionStrategy: .group(groupID: "no-group", topics: []),
5050
bootstrapServers: [self.bootstrapServer],
5151
brokerAddressFamily: .v4
@@ -57,7 +57,7 @@ final class SwiftKafkaTests: XCTestCase {
5757
}
5858

5959
override func tearDownWithError() throws {
60-
let basicConfig = KafkaConsumerConfig(
60+
let basicConfig = KafkaConsumerConfiguration(
6161
consumptionStrategy: .group(groupID: "no-group", topics: []),
6262
bootstrapServers: [self.bootstrapServer],
6363
brokerAddressFamily: .v4
@@ -94,7 +94,7 @@ final class SwiftKafkaTests: XCTestCase {
9494

9595
// Consumer Task
9696
group.addTask {
97-
let consumerConfig = KafkaConsumerConfig(
97+
let consumerConfig = KafkaConsumerConfiguration(
9898
consumptionStrategy: .group(groupID: "subscription-test-group-id", topics: [self.uniqueTestTopic]),
9999
autoOffsetReset: .beginning, // Always read topics from beginning
100100
bootstrapServers: [self.bootstrapServer],
@@ -151,7 +151,7 @@ final class SwiftKafkaTests: XCTestCase {
151151

152152
// Consumer Task
153153
group.addTask {
154-
let consumerConfig = KafkaConsumerConfig(
154+
let consumerConfiguration = KafkaConsumerConfiguration(
155155
consumptionStrategy: .partition(
156156
topic: self.uniqueTestTopic,
157157
partition: KafkaPartition(rawValue: 0),
@@ -163,7 +163,7 @@ final class SwiftKafkaTests: XCTestCase {
163163
)
164164

165165
let consumer = try KafkaConsumer(
166-
config: consumerConfig,
166+
config: consumerConfiguration,
167167
logger: .kafkaTest
168168
)
169169

@@ -212,7 +212,7 @@ final class SwiftKafkaTests: XCTestCase {
212212

213213
// Consumer Task
214214
group.addTask {
215-
let consumerConfig = KafkaConsumerConfig(
215+
let consumerConfig = KafkaConsumerConfiguration(
216216
consumptionStrategy: .group(groupID: "commit-sync-test-group-id", topics: [self.uniqueTestTopic]),
217217
enableAutoCommit: false,
218218
autoOffsetReset: .beginning, // Always read topics from beginning

Tests/SwiftKafkaTests/KafkaProducerTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ final class KafkaProducerTests: XCTestCase {
3535
let kafkaHost = ProcessInfo.processInfo.environment["KAFKA_HOST"] ?? "localhost"
3636
let kafkaPort = ProcessInfo.processInfo.environment["KAFKA_PORT"] ?? "9092"
3737
var bootstrapServer: String!
38-
var config: KafkaProducerConfig!
38+
var config: KafkaProducerConfiguration!
3939

4040
override func setUpWithError() throws {
4141
self.bootstrapServer = "\(self.kafkaHost):\(self.kafkaPort)"
4242

43-
self.config = KafkaProducerConfig(
43+
self.config = KafkaProducerConfiguration(
4444
bootstrapServers: [self.bootstrapServer],
4545
brokerAddressFamily: .v4
4646
)

scripts/soundness.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ unacceptable_terms=(
3636
# which is considered unacceptable by us.
3737
exclude_files=(
3838
CODE_OF_CONDUCT.md
39-
*Config.swift
39+
*Configuration.swift
4040
)
4141
for word in "${exclude_files[@]}"; do
4242
exclude_files+=(":(exclude)$word")

0 commit comments

Comments
 (0)