Created
December 1, 2018 21:50
-
-
Save dorsev/cd27e09a6beda6fc3e03d52a25ea7baf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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