• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

evolution-gaming / kafka-journal / 11837553250

14 Nov 2024 12:50PM CUT coverage: 83.298% (+0.2%) from 83.145%
11837553250

Pull #697

web-flow
Merge 1de7acaf5 into 916090a2c
Pull Request #697: make `version` non-optional

7 of 10 new or added lines in 5 files covered. (70.0%)

7 existing lines in 7 files now uncovered.

3167 of 3802 relevant lines covered (83.3%)

1.41 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

81.82
/core/src/main/scala/com/evolutiongaming/kafka/journal/Key.scala
1
package com.evolutiongaming.kafka.journal
2

3
import cats.kernel.Eq
4
import cats.syntax.all.*
5
import cats.{Functor, Order, Show}
6
import com.datastax.driver.core.{GettableByNameData, SettableData}
7
import com.evolutiongaming.catshelper.RandomIdOf
8
import com.evolutiongaming.scassandra.syntax.*
9
import com.evolutiongaming.scassandra.{DecodeRow, EncodeRow}
10
import com.evolutiongaming.skafka.Topic
11

12
final case class Key(id: String, topic: Topic) {
13

14
  override def toString = s"$topic:$id"
15
}
16

17
object Key {
18

19
  implicit val eqKey: Eq[Key] = Eq.fromUniversalEquals
1✔
20

21
  implicit val showKey: Show[Key] = Show.fromToString
1✔
22

UNCOV
23
  implicit val orderKey: Order[Key] = Order.whenEqual(Order.by { (a: Key) => a.topic }, Order.by { (a: Key) => a.id })
×
24

25
  implicit val orderingKey: Ordering[Key] = orderKey.toOrdering
1✔
26

27
  implicit val encodeRowKey: EncodeRow[Key] = new EncodeRow[Key] {
1✔
28

29
    def apply[B <: SettableData[B]](data: B, value: Key): B = {
30
      data
31
        .encode("id", value.id)
1✔
32
        .encode("topic", value.topic)
1✔
33
    }
34
  }
35

36
  implicit val decodeRowKey: DecodeRow[Key] = new DecodeRow[Key] {
1✔
37

38
    def apply(data: GettableByNameData): Key = {
39
      Key(id = data.decode[String]("id"), topic = data.decode[Topic]("topic"))
×
40
    }
41
  }
42

43
  def random[F[_]: Functor: RandomIdOf](topic: Topic): F[Key] = {
44
    for {
45
      randomId <- RandomIdOf[F].apply
1✔
46
    } yield {
47
      Key(id = randomId.value, topic = topic)
1✔
48
    }
49
  }
50
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc