MCPcopy Create free account
hub / github.com/Effect-TS/effect / layerProtocolSocket

Function layerProtocolSocket

packages/effect/src/rpc/RpcClient.ts:1559–1583  ·  view source on GitHub ↗
(options?: {
  readonly pingInterval?: Duration.Input | undefined
  readonly pingTimeout?: Duration.Input | undefined
  readonly retryTransientErrors?: boolean | undefined
  readonly retryPolicy?: Schedule.Schedule<any, Socket.SocketError> | undefined
  /**
   * Runs for each retried `SocketOpenError` when `retryTransientErrors` is enabled.
   * A ping timeout fails in-flight calls and is reported through `onPingTimeout`
   * instead. The returned `Effect<void>` cannot fail with a typed error or
   * require services; defects are logged and ignored so retries can continue.
   */
  readonly onTransientError?: ((error: RpcClientError) => Effect.Effect<void>) | undefined
  /**
   * Runs when an open connection is dropped because no server frame arrived
   * within `pingTimeout`, before `ConnectionHooks.onDisconnect` and before
   * in-flight calls fail with a `SocketReadError`. Defects are logged and ignored.
   *
   * @since 4.0.3
   */
  readonly onPingTimeout?: Effect.Effect<void> | undefined
})

Source from the content-addressed store, hash-verified

1557 * @since 4.0.0
1558 */
1559export const layerProtocolSocket = (options?: {
1560 readonly pingInterval?: Duration.Input | undefined
1561 readonly pingTimeout?: Duration.Input | undefined
1562 readonly retryTransientErrors?: boolean | undefined
1563 readonly retryPolicy?: Schedule.Schedule<any, Socket.SocketError> | undefined
1564 /**
1565 * Runs for each retried `SocketOpenError` when `retryTransientErrors` is enabled.
1566 * A ping timeout fails in-flight calls and is reported through `onPingTimeout`
1567 * instead. The returned `Effect<void>` cannot fail with a typed error or
1568 * require services; defects are logged and ignored so retries can continue.
1569 */
1570 readonly onTransientError?: ((error: RpcClientError) => Effect.Effect<void>) | undefined
1571 /**
1572 * Runs when an open connection is dropped because no server frame arrived
1573 * within `pingTimeout`, before `ConnectionHooks.onDisconnect` and before
1574 * in-flight calls fail with a `SocketReadError`. Defects are logged and ignored.
1575 *
1576 * @since 4.0.3
1577 */
1578 readonly onPingTimeout?: Effect.Effect<void> | undefined
1579}): Layer.Layer<
1580 Protocol,
1581 never,
1582 Socket.Socket | RpcSerialization.RpcSerialization
1583> => Layer.effect(Protocol)(makeProtocolSocket(options))
1584
1585/**
1586 * Creates a client `Protocol` backed by a pool of workers, routing RPC requests

Callers

nothing calls this directly

Calls 1

makeProtocolSocketFunction · 0.85

Tested by

no test coverage detected