-
Notifications
You must be signed in to change notification settings - Fork 1
/
EntryPointRootScope.scala
54 lines (46 loc) · 2.06 KB
/
EntryPointRootScope.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package com.dwolla.tracing.syntax
import cats.effect.MonadCancelThrow
import cats.mtl._
import natchez._
trait ToEntryPointRootScopeOps {
implicit def toEntryPointRootScopeOps[F[_]](entryPoint: EntryPoint[F]): EntryPointRootScopeOps[F] =
new EntryPointRootScopeOps(entryPoint)
}
class EntryPointRootScopeOps[F[_]](val entryPoint: EntryPoint[F]) extends AnyVal {
def runInRoot[A](name: String)
(fa: F[A])
(implicit F: MonadCancelThrow[F],
L: Local[F, Span[F]]): F[A] =
runInRoot(name, Span.Options.Defaults)(fa)
def runInRoot[A](name: String, options: Span.Options)
(fa: F[A])
(implicit F: MonadCancelThrow[F],
L: Local[F, Span[F]]): F[A] =
entryPoint
.root(name, options)
.use(Local[F, Span[F]].scope(fa))
def runInContinuation[A](name: String, kernel: Kernel)
(fa: F[A])
(implicit F: MonadCancelThrow[F],
L: Local[F, Span[F]]): F[A] =
runInContinuation(name, kernel, Span.Options.Defaults)(fa)
def runInContinuation[A](name: String, kernel: Kernel, options: Span.Options)
(fa: F[A])
(implicit F: MonadCancelThrow[F],
L: Local[F, Span[F]]): F[A] =
entryPoint
.continue(name, kernel, options)
.use(Local[F, Span[F]].scope(fa))
def runInContinuationOrElseRoot[A](name: String, kernel: Kernel)
(fa: F[A])
(implicit F: MonadCancelThrow[F],
L: Local[F, Span[F]]): F[A] =
runInContinuationOrElseRoot(name, kernel, Span.Options.Defaults)(fa)
def runInContinuationOrElseRoot[A](name: String, kernel: Kernel, options: Span.Options)
(fa: F[A])
(implicit F: MonadCancelThrow[F],
L: Local[F, Span[F]]): F[A] =
entryPoint
.continueOrElseRoot(name, kernel, options)
.use(Local[F, Span[F]].scope(fa))
}