| 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)! |