fd4s / fs2-kafka

Functional Kafka Streams for Scala
https://fd4s.github.io/fs2-kafka
Apache License 2.0
295 stars 100 forks source link

Provide functions for creating KafkaProducer test instances #235

Open vlovgr opened 4 years ago

vlovgr commented 4 years ago

Similarly to #234, it would be useful to provide functions for creating test KafkaProducers.

A good first function would be one which yields somewhat sensible default RecordMetadata.

object KafkaProducer {
  def unit[F[_], K, V](implicit F: Sync[F]): F[KafkaProducer[F, K, V]] = ???
}

Likely, this would require some internal state, hence F[KafkaProducer[F, K, V]].

hmagrahi commented 4 years ago

Hello, I'm trying to work on this issue, I have a question, the produce function returns a ProducerResult which it needs a RecordMetadata to create an instance of it, so should I fix static params for RecordMetadata (like topic, offset, timestamp.. )?

vlovgr commented 4 years ago

should I fix static params for RecordMetadata (like topic, offset, timestamp.. )

It would be great if we could use a Ref with some internal state, such that when we produce a record, we get back somewhat sensible RecordMetadata, i.e. not too different from what Kafka would actually return. At the very least, we should be able to have incrementing offsets per topic-partition.