-
Notifications
You must be signed in to change notification settings - Fork 97
/
package.scala
61 lines (48 loc) · 2.02 KB
/
package.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
* Copyright 2018-2022 OVO Energy Limited
*
* SPDX-License-Identifier: Apache-2.0
*/
package fs2
import cats.effect._
import scala.concurrent.duration.FiniteDuration
package object kafka {
type Id[+A] = A
/** Alias for Java Kafka `Consumer[Array[Byte], Array[Byte]]`. */
type KafkaByteConsumer =
org.apache.kafka.clients.consumer.Consumer[Array[Byte], Array[Byte]]
/** Alias for Java Kafka `Producer[Array[Byte], Array[Byte]]`. */
type KafkaByteProducer =
org.apache.kafka.clients.producer.Producer[Array[Byte], Array[Byte]]
/** Alias for Java Kafka `Deserializer[A]`. */
type KafkaDeserializer[A] =
org.apache.kafka.common.serialization.Deserializer[A]
/** Alias for Java Kafka `Serializer[A]`. */
type KafkaSerializer[A] =
org.apache.kafka.common.serialization.Serializer[A]
/** Alias for Java Kafka `Header`. */
type KafkaHeader =
org.apache.kafka.common.header.Header
/** Alias for Java Kafka `Headers`. */
type KafkaHeaders =
org.apache.kafka.common.header.Headers
/** Alias for Java Kafka `ConsumerRecords[Array[Byte], Array[Byte]]`. */
type KafkaByteConsumerRecords =
org.apache.kafka.clients.consumer.ConsumerRecords[Array[Byte], Array[Byte]]
/** Alias for Java Kafka `ConsumerRecord[Array[Byte], Array[Byte]]`. */
type KafkaByteConsumerRecord =
org.apache.kafka.clients.consumer.ConsumerRecord[Array[Byte], Array[Byte]]
/** Alias for Java Kafka `ProducerRecord[Array[Byte], Array[Byte]]`. */
type KafkaByteProducerRecord =
org.apache.kafka.clients.producer.ProducerRecord[Array[Byte], Array[Byte]]
/**
* Commits offsets in batches of every `n` offsets or time window
* of length `d`, whichever happens first. If there are no offsets
* to commit within a time window, no attempt will be made to commit
* offsets for that time window.
*/
def commitBatchWithin[F[_]](n: Int, d: FiniteDuration)(
implicit F: Temporal[F]
): Pipe[F, CommittableOffset[F], Unit] =
_.groupWithin(n, d).evalMap(CommittableOffsetBatch.fromFoldable(_).commit)
}