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

Method get

packages/cluster/src/internal/resourceMap.ts:45–65  ·  view source on GitHub ↗
(key: K)

Source from the content-addressed store, hash-verified

43 })
44
45 get(key: K): Effect.Effect<A, E> {
46 return Effect.withFiberRuntime((fiber) => {
47 if (MutableRef.get(this.isClosed)) {
48 return Effect.interrupt
49 }
50 const existing = backingGet(this.entries, key)
51 if (existing) {
52 return Deferred.await(existing.deferred)
53 }
54 const scope = Effect.runSync(Scope.make())
55 const deferred = Deferred.unsafeMake<A, E>(fiber.id())
56 backingSet(this.entries, key, { scope, deferred })
57 return Effect.onExit(this.lookup(key, scope), (exit) => {
58 if (exit._tag === "Success") {
59 return Deferred.done(deferred, exit)
60 }
61 backingDelete(this.entries, key)
62 return Effect.andThen(Deferred.done(deferred, exit), Scope.close(scope, exit))
63 })
64 })
65 }
66
67 remove(key: K): Effect.Effect<void> {
68 return Effect.suspend(() => {

Callers

nothing calls this directly

Calls 10

backingGetFunction · 0.85
backingSetFunction · 0.85
backingDeleteFunction · 0.85
getMethod · 0.65
makeMethod · 0.65
idMethod · 0.65
onExitMethod · 0.65
doneMethod · 0.65
closeMethod · 0.65
awaitMethod · 0.45

Tested by

no test coverage detected