Skip to content

Instantly share code, notes, and snippets.

@dorsev
Created December 1, 2018 21:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dorsev/cd27e09a6beda6fc3e03d52a25ea7baf to your computer and use it in GitHub Desktop.
Save dorsev/cd27e09a6beda6fc3e03d52a25ea7baf to your computer and use it in GitHub Desktop.
trait Trackable {
def setOffset(value: Long): Unit
}
trait Gauge {
def set(off: Long): Unit
}
val gauge: Gauge = ???
val counter: AtomicLong = ???
case class TrackableGauage() extends Gauge with Trackable {
override def set(off: Long): Unit = ??? /* Gauge impel of set method */
override def setOffset(value: Long): Unit = this.set(value)
}
case class TrackableAtomicLong() extends AtomicLong with Trackable {
override def setOffset(value: Long): Unit = this.set(value)
}
def offsetMonitor[F[_]: Functor, E, H[_]: Functor, T](monitor: H[Trackable]) = {
Flow[EnvT[E, F, ProducerResult[T]]].map { elem =>
elem.map { e =>
monitor.map { m =>
m.setOffset(e.env.offset)
}
}
elem
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment