MCPcopy Index your code
hub / github.com/Effect-TS/effect / accessHandler

Function accessHandler

packages/rpc/src/RpcGroup.ts:302–317  ·  view source on GitHub ↗
(this: RpcGroup<any>, tag: string)

Source from the content-addressed store, hash-verified

300 }))
301 },
302 accessHandler(this: RpcGroup<any>, tag: string) {
303 return Effect.contextWith((parentContext: Context.Context<any>) => {
304 const rpc = this.requests.get(tag)!
305 const { context, handler } = parentContext.unsafeMap.get(rpc.key) as Rpc.Handler<any>
306 return (payload: Rpc.Payload<any>, options: {
307 readonly clientId: number
308 readonly headers: Headers
309 }) => {
310 const result = handler(payload, options)
311 const effectOrStream = Rpc.isWrapper(result) ? result.value : result
312 return Effect.isEffect(effectOrStream)
313 ? Effect.provide(effectOrStream, context)
314 : Stream.provideContext(effectOrStream, context)
315 }
316 })
317 },
318 annotate(this: RpcGroup<any>, tag: Context.Tag<any, any>, value: any) {
319 return makeProto({
320 requests: this.requests,

Callers

nothing calls this directly

Calls 3

getMethod · 0.65
provideMethod · 0.65
handlerFunction · 0.50

Tested by

no test coverage detected