wix/greyhound

ZIO vs Vertx

OneCricketeer opened this issue · 3 comments

Hello!

So, I'm more of a pure Java person myself, but have an appreciation for higher level API and really find ZIO interesting, however I'm curious how this library compares with the Vertx client and would like to know if that was researched for the development or inspired any features you've added to this client? Same could be said about Alpakka or zio-kafka.

Thanks,
Keep up the good work!

Hi there,

I took a quick look at Vertx client. It seems to provide slightly simpler APIs than Kafka SDK, but it's still quite boilerplaty and is missing a few features that open-source version of greyhound already provides like order/unordered retry policies and out-of-the-box parallel consumption.

zio-kafka and Alpakka have taken a different approach with a more streams-like API with pipeline processing features like map, filter.

Thanks for the response!

quite boilerplaty

Could you elaborated?

open-source

Did you find
https://github.com/vert-x3/vertx-kafka-client?

@OneCricketeer Sorry for the late resposne.

wrt boilerplate. I think that greyhound API is a bit more fluent and straight forward:

Scala Future flavour

val config = GreyhoundConfig(environment.kafka.bootstrapServers)
GreyhoundConsumersBuilder(config)
      .withConsumer(
        GreyhoundConsumer(
          initialTopics = Set(topic),
          group = "group-1",
          clientId = "client-id-1",
          handle = aRecordHandler {
            new RecordHandler[Int, String] {
              override def handle(record: ConsumerRecord[Int, String])(implicit ec: ExecutionContext): Future[Any] =
                Future.successful(promise.success(record))
            }
          },
          keyDeserializer = Serdes.IntSerde,
          valueDeserializer = Serdes.StringSerde))

than Vert.x API (Which is still quite nice!)

Map<String, String> config = new HashMap<>();
config.put("bootstrap.servers", "localhost:9092");
config.put("key.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
config.put("value.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
config.put("group.id", "my_group");
config.put("auto.offset.reset", "earliest");
config.put("enable.auto.commit", "false");

// use consumer for interacting with Apache Kafka
KafkaConsumer<String, String> consumer = KafkaConsumer.create(vertx, config);

consumer.handler(record -> {
  System.out.println("Processing key=" + record.key() + ",value=" + record.value() +
    ",partition=" + record.partition() + ",offset=" + record.offset());
});

consumer.subscribe("a-single-topic");

We are going to refine the API further to have more defaults like Serde, ClientId, etc...
Also the Java API has room for improvement as well.

Did you find
https://github.com/vert-x3/vertx-kafka-client?
yes I did. this is what I was referring to. Didn't find any retry on error mechanism