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

Function onRequest

packages/rpc/src/RpcClient.ts:288–328  ·  view source on GitHub ↗
(rpc: Rpc.AnyWithProps)

Source from the content-addressed store, hash-verified

286 })
287
288 const onRequest = (rpc: Rpc.AnyWithProps) => {
289 const isStream = RpcSchema.isStreamSchema(rpc.successSchema)
290 const middleware = getRpcClientMiddleware(rpc)
291 return (payload: any, opts?: {
292 readonly asMailbox?: boolean | undefined
293 readonly streamBufferSize?: number | undefined
294 readonly headers?: Headers.Input | undefined
295 readonly context?: Context.Context<never> | undefined
296 readonly discard?: boolean | undefined
297 }) => {
298 const headers = opts?.headers ? Headers.fromInput(opts.headers) : Headers.empty
299 const context = opts?.context ?? Context.empty()
300 if (!isStream) {
301 const onRequest = (span: Span | undefined) =>
302 onEffectRequest(
303 rpc,
304 middleware,
305 span,
306 rpc.payloadSchema.make ? rpc.payloadSchema.make(payload) : payload,
307 headers,
308 context,
309 opts?.discard ?? false
310 )
311 return disableTracing ? onRequest(undefined) : Effect.useSpan(
312 `${spanPrefix}.${rpc._tag}`,
313 { captureStackTrace: false, attributes: options.spanAttributes },
314 onRequest
315 )
316 }
317 const mailbox = onStreamRequest(
318 rpc,
319 middleware,
320 rpc.payloadSchema.make ? rpc.payloadSchema.make(payload) : payload,
321 headers,
322 opts?.streamBufferSize ?? 16,
323 context
324 )
325 if (opts?.asMailbox) return mailbox
326 return Stream.unwrapScoped(Effect.map(mailbox, Mailbox.toStream))
327 }
328 }
329
330 const onEffectRequest = (
331 rpc: Rpc.AnyWithProps,

Callers 1

RpcClient.tsFile · 0.85

Calls 4

getRpcClientMiddlewareFunction · 0.85
onEffectRequestFunction · 0.85
makeMethod · 0.65
mapMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…