@@ -101,6 +101,7 @@ sealed abstract class CommittableOffsetBatch[F[_]] {
101
101
}
102
102
103
103
object CommittableOffsetBatch {
104
+
104
105
private [kafka] def apply [F [_]](
105
106
offsets : Map [TopicPartition , OffsetAndMetadata ],
106
107
consumerGroupIds : Set [String ],
@@ -140,7 +141,7 @@ object CommittableOffsetBatch {
140
141
141
142
override def commit : F [Unit ] =
142
143
if (_consumerGroupIdsMissing)
143
- F .raiseError(ConsumerGroupException (consumerGroupIds))
144
+ ApplicativeThrow [ F ] .raiseError(ConsumerGroupException (consumerGroupIds))
144
145
else {
145
146
offsetsByTopic
146
147
.map {
@@ -149,7 +150,7 @@ object CommittableOffsetBatch {
149
150
.getOrElse[Map [TopicPartition , OffsetAndMetadata ] => F [Unit ]](
150
151
topicName,
151
152
_ =>
152
- F .raiseError(
153
+ ApplicativeThrow [ F ] .raiseError(
153
154
new RuntimeException (s " Cannot perform commit for topic: $topicName" )
154
155
)
155
156
)
@@ -164,6 +165,36 @@ object CommittableOffsetBatch {
164
165
}
165
166
}
166
167
168
+ @ deprecated(" Use CommittableOffsetBatch.apply with commitMap instead." , since = " 2.5.1" )
169
+ private [kafka] def apply [F [_]](
170
+ offsets : Map [TopicPartition , OffsetAndMetadata ],
171
+ consumerGroupIds : Set [String ],
172
+ consumerGroupIdsMissing : Boolean ,
173
+ commit : Map [TopicPartition , OffsetAndMetadata ] => F [Unit ]
174
+ )(implicit F : ApplicativeError [F , Throwable ]): CommittableOffsetBatch [F ] =
175
+ apply[F ](
176
+ offsets,
177
+ consumerGroupIds,
178
+ consumerGroupIdsMissing,
179
+ offsets.headOption
180
+ .map(_._1.topic())
181
+ .map(topicName => Map (topicName -> commit))
182
+ .getOrElse(Map .empty)
183
+ )
184
+
185
+ /**
186
+ * A [[CommittableOffsetBatch ]] which does include only one offset for a single topic.
187
+ *
188
+ * @param topicPartition Topic partition information
189
+ * @param offsetAndMetadata Offset and metadata
190
+ * @param consumerGroupId Consumer group id
191
+ * @param commit effect to perform to commit this offset
192
+ * @tparam F effect type to use to perform the commit effect
193
+ * @return A [[CommittableOffsetBatch ]] which does include only one offset for a single topic.
194
+ *
195
+ * @see [[CommittableOffsetBatch#fromFoldable ]]
196
+ * @see [[CommittableOffsetBatch#fromFoldableOption ]]
197
+ */
167
198
def one [F [_]: ApplicativeThrow ](
168
199
topicPartition : TopicPartition ,
169
200
offsetAndMetadata : OffsetAndMetadata ,
0 commit comments