Skip to content

Commit

Permalink
fixup! Redesign context implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
NthPortal committed Aug 8, 2023
1 parent dc46bd4 commit 340a2a8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ import cats.effect.SyncIO

import scala.reflect.ClassTag

final class OpenContext private[transparent] (contents: Map[TypedKey[_], Any])
extends Context {
final case class OpenContext private[transparent] (
contents: Map[TypedKey[_], Any]
) extends Context {
type Self = OpenContext
type Key[A] = TypedKey[A]
type KeyBounds[A] = ClassTag[A]
Expand All @@ -31,15 +32,6 @@ final class OpenContext private[transparent] (contents: Map[TypedKey[_], Any])
contents.get(key).map(_.asInstanceOf[A])
def updated[A](key: TypedKey[A], value: A): OpenContext =
new OpenContext(contents.updated(key, value))

def entries: Iterator[OpenContext.Entry[_]] =
contents.iterator.map { case (key, value) =>
OpenContext.Entry(key, value)
}
}

object OpenContext extends OpenContextProvider[SyncIO] {
final case class Entry[A] private(key: TypedKey[A], value: A) {
def classTag: ClassTag[A] = key.tag
}
}
object OpenContext extends OpenContextProvider[SyncIO]
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ package org.typelevel.otel4s.java.context

import cats.effect.Sync
import io.opentelemetry.context.{Context => JContext}
import org.typelevel.otel4s.context.{Key, ContextProvider => CoreContextProvider}
import org.typelevel.otel4s.context.{ContextProvider => CoreContextProvider}
import org.typelevel.otel4s.context.Key

class ContextProvider[F[_]: Sync] private[context]
extends CoreContextProvider[F, Context] {
Expand Down

0 comments on commit 340a2a8

Please sign in to comment.