Created
February 24, 2018 23:33
-
-
Save leandrob13/34dbee5619020171dc1d1b7c93b4372b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import monix.eval.Task | |
import monix.execution.{CancelableFuture, Scheduler} | |
case class TracingIds(ids: Map[String, String]) extends TracingContext { | |
import TracingIds._ | |
def asCurrent[T](t: Task[T]): Task[T] = | |
TracingIds.bind(this)(t) | |
def execute[T](t: Task[T])(implicit sch: Scheduler, opt: Task.Options): CancelableFuture[T] = { | |
try local.bind(this)(t).runAsyncOpt | |
finally local.write(default).coeval.value | |
} | |
} | |
object TracingIds extends TracingContextCompanion[TracingIds] { | |
val default = TracingIds(Map.empty[String, String]) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment