-
Notifications
You must be signed in to change notification settings - Fork 18
Optimize Converters.topicPartitionsSetF #608
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,10 +2,9 @@ package com.evolutiongaming.skafka | |
|
|
||
| import java.lang.Long as LongJ | ||
| import java.time.Duration as DurationJ | ||
| import java.util.{Optional, Collection as CollectionJ, Map as MapJ, Set as SetJ, List as ListJ} | ||
|
|
||
| import java.util.{Optional, Collection as CollectionJ, List as ListJ, Map as MapJ, Set as SetJ} | ||
| import cats.Monad | ||
| import cats.data.{NonEmptyList as Nel, NonEmptySet as Nes, NonEmptyMap as Nem} | ||
| import cats.data.{NonEmptyList as Nel, NonEmptyMap as Nem, NonEmptySet as Nes} | ||
| import cats.syntax.all.* | ||
| import com.evolutiongaming.catshelper.CatsHelper.* | ||
| import com.evolutiongaming.catshelper.{ApplicativeThrowable, FromTry, MonadThrowable, ToTry} | ||
|
|
@@ -17,6 +16,7 @@ import org.apache.kafka.common.{PartitionInfo as PartitionInfoJ, TopicPartition | |
| import scala.compat.java8.DurationConverters | ||
| import scala.concurrent.duration.FiniteDuration | ||
| import scala.jdk.CollectionConverters.* | ||
| import scala.util.{Failure, Success, Try} | ||
|
|
||
| object Converters { | ||
|
|
||
|
|
@@ -233,9 +233,15 @@ object Converters { | |
| mapJ.asScalaMap(_.pure[F], partitionsInfoListF[F]) | ||
| } | ||
|
|
||
| def topicPartitionsSetF[F[_]: ApplicativeThrowable](setJ: SetJ[TopicPartitionJ]): F[Set[TopicPartition]] = { | ||
| for { | ||
| r <- setJ.asScala.toList.traverse { _.asScala[F] } | ||
| } yield r.toSet | ||
| } | ||
| def topicPartitionsSetF[F[_]: ApplicativeThrowable](setJ: SetJ[TopicPartitionJ]): F[Set[TopicPartition]] = | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was thinking about the soundness of the caller of this API... Very possibly this comment should be a dedicated issue! cc: @Z1kkurat IIUC, we call it after every
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree, the current approach to labeling metrics is very bizzare |
||
| ApplicativeThrowable[F].catchNonFatal { | ||
| val builder = Set.newBuilder[TopicPartition] | ||
| setJ.forEach { tpj => | ||
| tpj.asScala[Try] match { | ||
| case Failure(exception) => throw exception | ||
| case Success(value) => builder.addOne(value) | ||
| } | ||
| } | ||
| builder.result() | ||
| } | ||
|
Comment on lines
+236
to
+246
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
gh run view 31409780871 --job 93524765345 --log-failedRepository: evolution-gaming/skafka Length of output: 50379 🏁 Script executed: set -euo pipefail
log=/tmp/coderabbit-shell-logs/shell-output-7Vo8pu
printf '%s\n' '--- failure and conclusion markers ---'
rg -n -i 'error|failed|failure|aborted|exit code|process completed|all tests passed|success|cancelled|timed out' "$log" | tail -n 120
printf '%s\n' '--- final log lines ---'
tail -n 160 "$log"Repository: evolution-gaming/skafka Length of output: 46034 🏁 Script executed: set -euo pipefail
printf '%s\n' '--- changed files ---'
git diff --stat
printf '%s\n' '--- Converters.scala implementation and callers ---'
rg -n -C 8 'topicPartitionsSetF|SetJ\[TopicPartitionJ\]' skafka/src/main/scala skafka/src/test/scala
printf '%s\n' '--- failing test context ---'
sed -n '120,155p' skafka/src/test/scala/com/evolutiongaming/skafka/ProducerConsumerSpec.scala
sed -n '415,440p' skafka/src/test/scala/com/evolutiongaming/skafka/ProducerConsumerSpec.scala
printf '%s\n' '--- Converters.scala diff ---'
git diff -- skafka/src/main/scala/com/evolutiongaming/skafka/Converters.scalaRepository: evolution-gaming/skafka Length of output: 41603 🏁 Script executed: set -euo pipefail
printf '%s\n' '--- repository state ---'
git status --short
git rev-parse --short HEAD
printf '%s\n' '--- ProducerConsumerSpec location ---'
fd -t f 'ProducerConsumerSpec.scala' .
printf '%s\n' '--- test declaration and timeout helper ---'
file=$(fd -t f 'ProducerConsumerSpec.scala' . | head -n 1)
rg -n -C 12 'rebalance listener correctness|consumer\.commit|33 seconds|def timeout|TimeoutException' "$file"
printf '%s\n' '--- commit files for the reviewed path ---'
git diff --name-status
git show --stat --oneline --decorate HEADRepository: evolution-gaming/skafka Length of output: 7120 🏁 Script executed: set -euo pipefail
git show --format=fuller --no-ext-diff -- skafka/src/main/scala/com/evolutiongaming/skafka/Converters.scala skafka/src/main/scala/com/evolutiongaming/skafka/Partition.scala
printf '%s\n' '--- commit-path call graph ---'
rg -n -C 10 'def commit|commit\(|onPartitionsRevoked|RebalanceListener1WithConsumer|topicPartitionsSetF' \
skafka/src/main/scala/com/evolutiongaming/skafka/consumer \
tests/src/test/scala/com/evolutiongaming/skafka/ProducerConsumerSpec.scalaRepository: evolution-gaming/skafka Length of output: 50380 Resolve the Scala 3.3.8 test failure before merging.
🤖 Prompt for AI AgentsSource: MCP tools
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. flaky test, green now There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
You are interacting with an AI system. |
||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.