Skip to content

Commit 8c77ea1

Browse files
add/change some comments
1 parent ce702f3 commit 8c77ea1

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

Sources/SwiftKafka/KafkaTransactionalProducer.swift

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public final class KafkaTransactionalProducer: Service, Sendable {
1414
///
1515
/// This creates a producer without listening for events.
1616
///
17-
/// - Parameter config: The ``KafkaProducerConfiguration`` for configuring the ``KafkaProducer``.
17+
/// - Parameter config: The ``KafkaTransactionalProducerConfiguration`` for configuring the ``KafkaProducer``.
1818
/// - Parameter topicConfig: The ``KafkaTopicConfiguration`` used for newly created topics.
1919
/// - Parameter logger: A logger.
2020
/// - Returns: The newly created ``KafkaProducer``.
@@ -57,15 +57,18 @@ public final class KafkaTransactionalProducer: Service, Sendable {
5757
return (transactionalProducer, events)
5858
}
5959

60-
//
61-
public func withTransaction(_ body: @Sendable (KafkaTransaction) async throws -> Void) async throws {
60+
/// Begins Kafka transaction, provides it to given closure
61+
/// Commits transaction unless closure throws
62+
/// - Parameters:
63+
/// - function: revieve KafkaTransaction and use fills it with produced messages and offsets
64+
public func withTransaction(_ function: @Sendable (KafkaTransaction) async throws -> Void) async throws {
6265
let transaction = try KafkaTransaction(
6366
client: try producer.client(),
6467
producer: self.producer
6568
)
6669

6770
do { // need to think here a little bit how to abort transaction
68-
try await body(transaction)
71+
try await function(transaction)
6972
try await transaction.commit()
7073
} catch { // FIXME: maybe catch AbortTransaction?
7174
do {

Tests/IntegrationTests/Utilities.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import Logging
2020
extension Logger {
2121
static var kafkaTest: Logger {
2222
var logger = Logger(label: "kafka.test")
23-
logger.logLevel = .debug
23+
logger.logLevel = .debug // TODO: revert
2424
return logger
2525
}
2626
}

0 commit comments

Comments
 (0)