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

Function toLayerHandler

packages/effect/src/unstable/rpc/RpcGroup.ts:331–345  ·  view source on GitHub ↗
(this: RpcGroup<any>, service: string, build: Effect.Effect<Record<string, (request: any) => any>>)

Source from the content-addressed store, hash-verified

329 },
330 of: identity,
331 toLayerHandler(this: RpcGroup<any>, service: string, build: Effect.Effect<Record<string, (request: any) => any>>) {
332 // oxlint-disable-next-line no-this-alias
333 const self = this
334 return Layer.effectContext(Effect.gen(function*() {
335 const services = yield* Effect.context<never>()
336 const handler = Effect.isEffect(build) ? yield* build : build
337 const contextMap = new Map<string, unknown>()
338 const rpc = self.requests.get(service)!
339 contextMap.set(rpc.key, {
340 handler,
341 context: services
342 })
343 return Context.makeUnsafe(contextMap)
344 }))
345 },
346 accessHandler(this: RpcGroup<any>, service: string) {
347 return Effect.contextWith((parentContext: Context.Context<any>) => {
348 const rpc = this.requests.get(service)!

Callers

nothing calls this directly

Calls 3

contextMethod · 0.80
getMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected