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

Function onRequest

repos/effect/packages/effect/src/unstable/rpc/RpcClient.ts:303–343  ·  view source on GitHub ↗
(rpc: Rpc.AnyWithProps)

Source from the content-addressed store, hash-verified

301 } else {
302 entry.resume(exit)
303 }
304 }
305 })
306
307 const onRequest = (rpc: Rpc.AnyWithProps) => {
308 const isStream = RpcSchema.isStreamSchema(rpc.successSchema)
309 const middleware = getRpcClientMiddleware(rpc)
310 return (payload: any, opts?: {
311 readonly asQueue?: boolean | undefined
312 readonly streamBufferSize?: number | undefined
313 readonly headers?: Headers.Input | undefined
314 readonly context?: Context.Context<never> | undefined
315 readonly discard?: boolean | undefined
316 }) => {
317 const headers = opts?.headers ? Headers.fromInput(opts.headers) : Headers.empty
318 const context = opts?.context ?? Context.empty()
319 if (!isStream) {
320 const onRequest = (span: Span | undefined) =>
321 onEffectRequest(
322 rpc,
323 middleware,
324 span,
325 rpc.payloadSchema.make(payload),
326 headers,
327 context,
328 opts?.discard ?? false
329 )
330 return disableTracing ? onRequest(undefined) : Effect.useSpan(
331 `${spanPrefix}.${rpc._tag}`,
332 { attributes: options.spanAttributes },
333 onRequest
334 )
335 }
336 const queue = onStreamRequest(
337 rpc,
338 middleware,
339 rpc.payloadSchema.make(payload),
340 headers,
341 opts?.streamBufferSize ?? 16,
342 context
343 )
344 if (opts?.asQueue) return queue
345 return Stream.unwrap(Effect.map(queue, Stream.fromQueue))
346 }

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…