(rpc: Rpc.AnyWithProps)
| 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, |
no test coverage detected