Skip to content

RpcSchema

RPC schema markers and interruption annotations.

This module contains the small pieces of schema metadata that the RPC declaration, client, server, cluster, and reactivity layers share. It marks streamed responses and annotates interruptions that came from a remote client closing or cancelling a request.

4 exports Added in v4.0.0 Source

Constructors

Stream

Added in v4.0.0 Source

Creates an RPC stream schema from a stream element success schema and stream error schema.

Signature

declare function Stream<A extends Constraint, E extends Constraint>(
  success: A,
  error: E,
): Stream<A, E>;

Guards

Returns true when a schema is an RPC stream schema created by RpcSchema.Stream.

Signature

declare function isStreamSchema(schema: Constraint): schema is Stream<Top, Top>;

Models

Stream interface

Added in v4.0.0 Source

A schema marker for RPC streaming responses, storing the success element schema and stream error schema used for encoding and decoding stream chunks.

Signature

interface Stream<A extends Schema.Constraint, E extends Schema.Constraint> extends BottomLazy<
  SchemaAST.Declaration,
  Stream<A, E>
> {
  constructor(_: never);
  readonly "~effect/rpc/RpcSchema/StreamSchema": "~effect/rpc/RpcSchema/StreamSchema";
  readonly "~type.make": Stream<A["Type"], E["Type"]>;
  readonly "~type.make.in": Stream<A["Type"], E["Type"]>;
  readonly DecodingServices: A["DecodingServices"] | E["DecodingServices"];
  readonly Encoded: Stream<A["Encoded"], E["Encoded"]>;
  readonly EncodingServices: A["EncodingServices"] | E["EncodingServices"];
  readonly error: E;
  readonly Iso: Stream<A["Type"], E["Type"]>;
  readonly Rebuild: Stream<A, E>;
  readonly success: A;
  readonly Type: Stream<A["Type"], E["Type"]>;
}

Services

ClientAbort

Added in v4.0.0 Source

Annotation that marks interruptions that originate from an RPC client abort.

Signature

declare class ClientAbort extends Shape<"effect/rpc/RpcSchema/ClientAbort", true, this> {
  constructor(_: never);
  static annotation: Context<StackTrace | ClientAbort>;
}