All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.evolutiongaming.kafka.journal.AppendMarker.scala Maven / Gradle / Ivy

The newest version!
package com.evolutiongaming.kafka.journal

import cats.FlatMap
import cats.syntax.all._

trait AppendMarker[F[_]] {
  
  def apply(key: Key): F[Marker]
}

object AppendMarker {

  def apply[F[_] : FlatMap : RandomIdOf](
    produce: Produce[F],
  ): AppendMarker[F] = {

    key: Key => {
      for {
        randomId        <- RandomIdOf[F].apply
        partitionOffset <- produce.mark(key, randomId)
      } yield {
        Marker(randomId.value, partitionOffset)
      }
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy