MCPcopy Create free account
hub / github.com/effect-app/libs / ensureStore

Function ensureStore

packages/infra/src/Store/Memory.ts:539–552  ·  view source on GitHub ↗
(namespace: string)

Source from the content-addressed store, hash-verified

537 return sem
538 }
539 const ensureStore = (namespace: string) =>
540 getSem(namespace).withPermits(1)(Effect.suspend(() => {
541 const store = stores.get(namespace)
542 if (store) return Effect.succeed(store)
543 if (config?.allowNamespace && !config.allowNamespace(namespace)) {
544 throw new Error(`Namespace ${namespace} not allowed!`)
545 }
546 return makeMemoryStoreInt(modelName, idKey, namespace, seed, config?.defaultValues)
547 .pipe(
548 Effect.orDie,
549 Effect.provide(ctx),
550 Effect.tap((store) => Effect.sync(() => stores.set(namespace, store)))
551 )
552 }))
553 const getStore = !config?.allowNamespace
554 ? Effect.succeed(primary)
555 : storeId.pipe(Effect.flatMap((namespace) => ensureStore(namespace)))

Callers 1

makeMemoryStoreFunction · 0.70

Calls 9

makeMemoryStoreIntFunction · 0.85
syncMethod · 0.80
getSemFunction · 0.70
withPermitsMethod · 0.65
getMethod · 0.65
pipeMethod · 0.65
setMethod · 0.65
succeedMethod · 0.45
provideMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…