@@ -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 {
0 commit comments