zio / zio-kafka

A Kafka client for ZIO and ZIO Streams
https://zio.dev/zio-kafka
Apache License 2.0
341 stars 138 forks source link

Add support for embedded-kafka-schema-registry to the testkit #1196

Open bbarker opened 8 months ago

bbarker commented 8 months ago

I have a version of this working locally and would be happy to get a PR submitted once I kick the tires on it a bit more. But let me know of any requirements that you might want for this and if it would be a welcome addition. Currently it reflects the existing Kafka layer with very few changes, e.g. :

import _root_.kafka.server.KafkaConfig
import io.github.embeddedkafka.schemaregistry.{EmbeddedKWithSR, EmbeddedKafka, EmbeddedKafkaConfig}
import zio.*

object KafkaSchemaRegistry {

  /**
   * Creates an in-memory Kafka instance with a random port.
   */
  def embedded: ZLayer[Any, Throwable, Kafka] = embeddedWith(_ => Map.empty)

// ....
erikvanoosten commented 8 months ago

Maybe the other maintainers think differently about this, but I would prefer not to mix support for Confluent's schema registry with support for Apache's Kafka in the same repository (or at least, not in the same library).

bbarker commented 8 months ago

Maybe another testkit module that depends on the existing testkit? Then the question is would it be good to host within this repo or not (and as a submodule of the root or not).

guizmaii commented 8 months ago

Personally, I'm ok to provide it in zio-kafka. The Confluent Schema Registry is kind of the norm in the Kafka world and, to me, it makes sense for us to provide such helper in our testkit. Happy to review any PR bringing this @bbarker. Putting it in another module make sense to me. That can allow people to bring support of different registries by adding an sbt module per registry

erikvanoosten commented 8 months ago

Its the norm because unfortunately Confluent's Schema Registry is the best there is. Still, there are many Kafka deployments that do not use it. In addition, Confluent's libraries can only be gotten from their own maven repository. I think a separate module would save a lot of headaches for people that don't want to use it.