Skip to content
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

Update code to use modern cats import #765

Merged
merged 1 commit into from
Jan 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
/website/variables.js
/website/yarn.lock
target/
.metals/
.vscode/
2 changes: 1 addition & 1 deletion docs/src/main/mdoc/admin.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ The following imports are assumed throughout this page.

```scala mdoc:silent
import cats.effect._
import cats.implicits._
import cats.syntax.all._
import fs2.Stream
import fs2.kafka._
```
Expand Down
6 changes: 3 additions & 3 deletions docs/src/main/mdoc/consumers.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The following imports are assumed throughout this page.

```scala mdoc:silent
import cats.effect._
import cats.implicits._
import cats.syntax.all._
import fs2.kafka._
import scala.concurrent.duration._
```
Expand Down Expand Up @@ -356,12 +356,12 @@ object WithGracefulShutdownExample extends IOApp {
}

def handleError(e: Throwable): IO[Unit] = IO(println(e.toString))

for {
stoppedDeferred <- Deferred[IO, Either[Throwable, Unit]] // [1]
gracefulShutdownStartedRef <- Ref[IO].of(false) // [2]
_ <- KafkaConsumer.resource(consumerSettings)
.allocated.bracketCase { case (consumer, _) => // [3]
.allocated.bracketCase { case (consumer, _) => // [3]
run(consumer).attempt.flatMap { result: Either[Throwable, Unit] => // [4]
gracefulShutdownStartedRef.get.flatMap {
case true => stoppedDeferred.complete(result) // [5]
Expand Down
2 changes: 1 addition & 1 deletion docs/src/main/mdoc/modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ resolvers += "confluent" at "https://packages.confluent.io/maven/",
We start by defining the type we want to serialize or deserialize, and create a `Codec`.

```scala mdoc:reset-object
import cats.implicits._
import cats.syntax.all._
import vulcan.Codec

final case class Person(name: String, age: Option[Int])
Expand Down
2 changes: 1 addition & 1 deletion docs/src/main/mdoc/producers.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The following imports are assumed throughout this page.

```scala mdoc:silent
import cats.effect._
import cats.implicits._
import cats.syntax.all._
import fs2.kafka._
import scala.concurrent.duration._
```
Expand Down
2 changes: 1 addition & 1 deletion modules/core/src/main/scala/fs2/kafka/ConsumerRecord.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

package fs2.kafka

import cats.implicits._
import cats.syntax.all._
import cats.{Applicative, Apply, Bitraverse, Eq, Eval, Show, Traverse}
import fs2.kafka.internal.syntax._
import org.apache.kafka.clients.consumer.ConsumerRecord.{NO_TIMESTAMP, NULL_SIZE}
Expand Down
2 changes: 1 addition & 1 deletion modules/core/src/main/scala/fs2/kafka/Deserializer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ package fs2.kafka

import cats.MonadError
import cats.effect.Sync
import cats.implicits._
import cats.syntax.all._
import java.nio.charset.{Charset, StandardCharsets}
import java.util.UUID

Expand Down
2 changes: 1 addition & 1 deletion modules/core/src/main/scala/fs2/kafka/KafkaProducer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
package fs2.kafka

import cats.effect._
import cats.implicits._
import cats.syntax.all._
import cats.{Apply, Functor}
import fs2.{Chunk, _}
import fs2.kafka.internal._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
package fs2.kafka

import cats.effect._
import cats.implicits._
import cats.syntax.all._
import fs2.Stream
import fs2.kafka.internal._
import fs2.kafka.producer.MkProducer
Expand Down
2 changes: 1 addition & 1 deletion modules/core/src/main/scala/fs2/kafka/Serializer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ package fs2.kafka

import cats.Contravariant
import cats.effect.Sync
import cats.implicits._
import cats.syntax.all._
import java.nio.charset.{Charset, StandardCharsets}
import java.util.UUID

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
package fs2.kafka.internal

import cats.data.{Chain, NonEmptyList, NonEmptySet, NonEmptyVector}
import cats.implicits._
import cats.syntax.all._
import fs2.Chunk
import fs2.kafka.CommittableConsumerRecord
import fs2.kafka.instances._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
package fs2.kafka.internal

import cats.effect.Sync
import cats.implicits._
import cats.syntax.all._
import org.slf4j.LoggerFactory

private[kafka] sealed abstract class Logging[F[_]] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
package fs2.kafka.internal

import cats.effect.{Async, Resource, Sync}
import cats.implicits._
import cats.syntax.all._
import fs2.kafka.AdminClientSettings
import fs2.kafka.admin.MkAdminClient
import fs2.kafka.internal.syntax._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
package fs2.kafka.internal

import cats.effect.{Async, Resource}
import cats.implicits._
import cats.syntax.all._
import fs2.kafka.consumer.MkConsumer
import fs2.kafka.{ConsumerSettings, KafkaByteConsumer}
import fs2.kafka.internal.syntax._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ package fs2.kafka.internal

import fs2.kafka.producer.MkProducer
import cats.effect.{Async, Resource}
import cats.implicits._
import cats.syntax.all._
import fs2.kafka.{KafkaByteProducer, ProducerSettings, TransactionalProducerSettings}
import fs2.kafka.internal.syntax._

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ package fs2.kafka.internal
import cats.{FlatMap, Foldable, Show}
import cats.effect.Async
import cats.effect.syntax.all._
import cats.implicits._
import cats.syntax.all._
import fs2.kafka.{Header, Headers, KafkaHeaders}
import fs2.kafka.internal.converters.unsafeWrapArray
import fs2.kafka.internal.converters.collection._
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package fs2.kafka

import cats.implicits._
import cats.syntax.all._
import org.apache.kafka.clients.admin.AdminClientConfig
import scala.concurrent.duration._

Expand Down
2 changes: 1 addition & 1 deletion modules/core/src/test/scala/fs2/kafka/BaseGenerators.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package fs2.kafka

import cats.{ApplicativeError, ApplicativeThrow}
import cats.effect._
import cats.implicits._
import cats.syntax.all._
import org.apache.kafka.clients.consumer.OffsetAndMetadata
import org.apache.kafka.common.TopicPartition
import org.scalacheck.Arbitrary.arbitrary
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package fs2.kafka

import cats.effect.IO
import cats.implicits._
import cats.syntax.all._
import org.apache.kafka.clients.consumer.OffsetAndMetadata
import org.apache.kafka.common.TopicPartition

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package fs2.kafka

import cats.effect.IO
import cats.implicits._
import cats.syntax.all._
import org.apache.kafka.clients.consumer.OffsetAndMetadata
import org.apache.kafka.common.TopicPartition
import org.scalacheck.Gen
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package fs2.kafka

import cats.effect.IO
import cats.effect.unsafe.implicits.global
import cats.implicits._
import cats.syntax.all._
import org.apache.kafka.clients.consumer.OffsetAndMetadata
import org.apache.kafka.common.TopicPartition

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package fs2.kafka

import cats.effect.IO
import cats.effect.unsafe.implicits.global
import cats.implicits._
import cats.syntax.all._
import org.apache.kafka.clients.consumer.ConsumerRecord.{NULL_SIZE, NO_TIMESTAMP}
import org.apache.kafka.common.record.TimestampType
import org.apache.kafka.common.record.TimestampType._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package fs2.kafka

import cats.effect.IO
import cats.effect.unsafe.implicits.global
import cats.implicits._
import cats.syntax.all._
import org.apache.kafka.clients.consumer.ConsumerConfig

import scala.concurrent.ExecutionContext
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package fs2.kafka

import cats.effect.{IO, SyncIO}
import cats.implicits._
import cats.syntax.all._
import cats.effect.unsafe.implicits.global
import org.apache.kafka.clients.admin.{AlterConfigOp, ConfigEntry, NewPartitions, NewTopic}
import org.apache.kafka.clients.consumer.OffsetAndMetadata
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import cats.data.NonEmptySet
import cats.effect.Ref
import cats.effect.{Fiber, IO}
import cats.effect.std.Queue
import cats.implicits._
import cats.syntax.all._
import cats.effect.unsafe.implicits.global
import fs2.Stream
import fs2.concurrent.SignallingRef
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package fs2.kafka

import cats.effect.IO
import cats.effect.unsafe.implicits.global
import cats.implicits._
import cats.syntax.all._
import fs2.{Chunk, Stream}

final class KafkaProducerSpec extends BaseKafkaSpec {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package fs2.kafka

import cats.implicits._
import cats.syntax.all._

final class ProducerRecordsSpec extends BaseSpec {
describe("ProducerRecords") {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package fs2.kafka

import fs2.Chunk
import cats.implicits._
import cats.syntax.all._
import org.apache.kafka.clients.producer.RecordMetadata
import org.apache.kafka.common.TopicPartition

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package fs2.kafka

import cats.effect.IO
import cats.effect.unsafe.implicits.global
import cats.implicits._
import cats.syntax.all._
import org.apache.kafka.clients.producer.ProducerConfig

import scala.concurrent.ExecutionContext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import java.util
import cats.data.NonEmptyList
import cats.effect.IO
import cats.effect.unsafe.implicits.global
import cats.implicits._
import cats.syntax.all._
import fs2.{Chunk, Stream}
import fs2.kafka.internal.converters.collection._
import fs2.kafka.producer.MkProducer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ package fs2.kafka.vulcan

import _root_.vulcan.Codec
import cats.effect.Sync
import cats.implicits._
import cats.syntax.all._
import fs2.kafka.{Deserializer, RecordDeserializer}
import io.confluent.kafka.schemaregistry.avro.AvroSchema
import java.nio.ByteBuffer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ package fs2.kafka.vulcan

import _root_.vulcan.Codec
import cats.effect.Sync
import cats.implicits._
import cats.syntax.all._
import fs2.kafka.{RecordSerializer, Serializer}

final class AvroSerializer[A] private[vulcan] (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
package fs2.kafka.vulcan

import cats.effect.Sync
import cats.implicits._
import cats.syntax.all._
import fs2.kafka.internal.converters.collection._
import fs2.kafka.internal.syntax._

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package fs2.kafka.vulcan

import java.time.Instant

import cats.implicits._
import cats.syntax.all._
import cats.effect.IO
import cats.effect.unsafe.implicits.global
import fs2.kafka._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package fs2.kafka.vulcan

import cats.effect.IO
import cats.effect.unsafe.implicits.global
import cats.implicits._
import cats.syntax.all._
import org.scalatest.funspec.AnyFunSpec
import org.scalatestplus.scalacheck._

Expand Down
4 changes: 2 additions & 2 deletions scalafix/input/src/main/scala/fix/PassthroughParams.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ rule = Fs2Kafka
package fix

import fs2.kafka._
import cats.implicits._
import cats.syntax.all._
import fs2.Chunk
import cats.effect.IO

Expand Down Expand Up @@ -35,7 +35,7 @@ class PassthroughParams {
val result: ProducerResult[String, String, Int] =
ProducerResult[String, String, Int](Chunk.empty, 42)

val tRecords: TransactionalProducerRecords[IO, String, String, Int] =
val tRecords: TransactionalProducerRecords[IO, String, String, Int] =
TransactionalProducerRecords[IO, String, String, Int](Chunk.empty, 42)

TransactionalProducerRecords.one[IO, String, String, Int](???, 42)
Expand Down
4 changes: 2 additions & 2 deletions scalafix/output/src/main/scala/fix/PassthroughParams.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package fix

import fs2.kafka._
import cats.implicits._
import cats.syntax.all._
import fs2.Chunk
import cats.effect.IO

Expand Down Expand Up @@ -31,7 +31,7 @@ class PassthroughParams {
val result: ProducerResult[Int, String, String] =
ProducerResult[Int, String, String](Chunk.empty, 42)

val tRecords: TransactionalProducerRecords[IO, Int, String, String] =
val tRecords: TransactionalProducerRecords[IO, Int, String, String] =
TransactionalProducerRecords[IO, Int, String, String](Chunk.empty, 42)

TransactionalProducerRecords.one[IO, Int, String, String](???, 42)
Expand Down