MCPcopy Create free account
hub / github.com/Effect-TS/effect / setContext

Method setContext

packages/effect/src/internal/effect.ts:708–730  ·  view source on GitHub ↗
(context: Context.Context<never>)

Source from the content-addressed store, hash-verified

706 return pipeArguments(this, arguments)
707 }
708 setContext(context: Context.Context<never>): void {
709 const previous = this.context
710 this.context = context
711 // Every key cached below opts in to Context caching, so contexts related
712 // only by non-caching adds cannot have changed any of them
713 if (previous !== undefined && Context.hasSameCache(previous, context)) return
714 const scheduler = this.getRef(Scheduler.Scheduler)
715 if (scheduler !== this.currentScheduler) {
716 this.currentScheduler = scheduler
717 this._dispatcher = undefined
718 }
719 // The string-keyed lookups keep the Tracer key values (and the native
720 // tracer behind Tracer.Tracer's default) out of every bundle
721 this.currentSpan = Context.getOrUndefinedUnsafe(context, Tracer.ParentSpanKey)
722 this.currentLogLevel = this.getRef(CurrentLogLevel)
723 this.minimumLogLevel = this.getRef(MinimumLogLevel)
724 this.currentStackFrame = this.getRef(CurrentStackFrame)
725 this.maxOpsBeforeYield = this.getRef(Scheduler.MaxOpsBeforeYield)
726 this.currentPreventYield = this.getRef(Scheduler.PreventSchedulerYield)
727 this.runtimeMetrics = Context.getOrUndefinedUnsafe(context, InternalMetric.FiberRuntimeMetricsKey)
728 const currentTracer = Context.getOrUndefinedUnsafe<Tracer.Tracer>(context, Tracer.TracerKey)
729 this.currentTracerContext = currentTracer ? currentTracer["context"] : undefined
730 }
731 get currentSpanLocal(): Tracer.Span | undefined {
732 return this.currentSpan?._tag === "Span" ? this.currentSpan : undefined
733 }

Callers 1

constructorMethod · 0.95

Calls 1

getRefMethod · 0.95

Tested by

no test coverage detected