RpcClient.ts overview
Since v1.0.0
Exports Grouped by Category
client
FromGroup (type alias)
Signature
type { [K in keyof (RpcClient.From<Exclude<RpcGroup.Rpcs<Group>, { readonly _tag: `${string}.${string}`; }>, never, ""> & { readonly [CurrentPrefix in RpcClient.Prefixes<RpcGroup.Rpcs<Group>>]: RpcClient.From<Extract<RpcGroup.Rpcs<Group>, { readonly _tag: `${CurrentPrefix}.${string}`; }>, never, CurrentPrefix>; })]: (RpcClient.From<Exclude<RpcGroup.Rpcs<Group>, { readonly _tag: `${string}.${string}`; }>, never, ""> & { readonly [CurrentPrefix in RpcClient.Prefixes<RpcGroup.Rpcs<Group>>]: RpcClient.From<Extract<RpcGroup.Rpcs<Group>, { readonly _tag: `${CurrentPrefix}.${string}`; }>, never, CurrentPrefix>; })[K]; } = RpcClient<RpcGroup.Rpcs<Group>>
Since v1.0.0
RpcClient (type alias)
Signature
type { [K in keyof (RpcClient.From<Exclude<Rpcs, { readonly _tag: `${string}.${string}`; }>, E, ""> & { readonly [CurrentPrefix in RpcClient.Prefixes<Rpcs>]: RpcClient.From<Extract<Rpcs, { readonly _tag: `${CurrentPrefix}.${string}`; }>, E, CurrentPrefix>; })]: (RpcClient.From<Exclude<Rpcs, { readonly _tag: `${string}.${string}`; }>, E, ""> & { readonly [CurrentPrefix in RpcClient.Prefixes<Rpcs>]: RpcClient.From<Extract<Rpcs, { readonly _tag: `${CurrentPrefix}.${string}`; }>, E, CurrentPrefix>; })[K]; } = Schema.Simplify<
& RpcClient.From<RpcClient.NonPrefixed<Rpcs>, E, "">
& {
readonly [CurrentPrefix in RpcClient.Prefixes<Rpcs>]: RpcClient.From<
RpcClient.Prefixed<Rpcs, CurrentPrefix>,
E,
CurrentPrefix
>
}
>
Since v1.0.0
RpcClient (namespace)
Since v1.0.0
Prefixes (type alias)
Signature
type Prefixes<Rpcs> = Rpcs["_tag"] extends infer Tag
? Tag extends `${infer Prefix}.${string}`
? Prefix
: never
: never
Since v1.0.0
NonPrefixed (type alias)
Signature
type NonPrefixed<Rpcs> = Exclude<Rpcs, { readonly _tag: `${string}.${string}` }>
Since v1.0.0
Prefixed (type alias)
Signature
type Prefixed<Rpcs, Prefix> = Extract<Rpcs, { readonly _tag: `${Prefix}.${string}` }>
Since v1.0.0
From (type alias)
Signature
type From<Rpcs, E, Prefix> = {
readonly [Current in Rpcs as Current["_tag"] extends `${Prefix}.${infer Method}` ? Method : Current["_tag"]]: <
const AsMailbox extends boolean = false,
const Discard = false
>(
input: Rpc.PayloadConstructor<Current>,
options?: Rpc.Success<Current> extends Stream.Stream<infer _A, infer _E, infer _R>
? {
readonly asMailbox?: AsMailbox | undefined
readonly streamBufferSize?: number | undefined
readonly headers?: Headers.Input | undefined
readonly context?: Context.Context<never> | undefined
}
: {
readonly headers?: Headers.Input | undefined
readonly context?: Context.Context<never> | undefined
readonly discard?: Discard | undefined
}
) => Current extends Rpc.Rpc<infer _Tag, infer _Payload, infer _Success, infer _Error, infer _Middleware>
? [_Success] extends [RpcSchema.Stream<infer _A, infer _E>]
? AsMailbox extends true
? Effect.Effect<
Mailbox.ReadonlyMailbox<_A["Type"], _E["Type"] | _Error["Type"] | E>,
never,
Scope.Scope | _Payload["Context"] | _Success["Context"] | _Error["Context"]
>
: Stream.Stream<
_A["Type"],
_E["Type"] | _Error["Type"] | E,
_Payload["Context"] | _Success["Context"] | _Error["Context"]
>
: Effect.Effect<
Discard extends true ? void : _Success["Type"],
Discard extends true ? E : _Error["Type"] | E,
_Payload["Context"] | _Success["Context"] | _Error["Context"]
>
: never
}
Since v1.0.0
Flat (type alias)
Signature
type Flat<Rpcs, E> = <const Tag extends Rpcs["_tag"], const AsMailbox extends boolean = false, const Discard = false>(
tag: Tag,
payload: Rpc.PayloadConstructor<Rpc.ExtractTag<Rpcs, Tag>>,
options?: Rpc.Success<Rpc.ExtractTag<Rpcs, Tag>> extends Stream.Stream<infer _A, infer _E, infer _R>
? {
readonly asMailbox?: AsMailbox | undefined
readonly streamBufferSize?: number | undefined
readonly headers?: Headers.Input | undefined
readonly context?: Context.Context<never> | undefined
}
: {
readonly headers?: Headers.Input | undefined
readonly context?: Context.Context<never> | undefined
readonly discard?: Discard | undefined
}
) => Rpc.ExtractTag<Rpcs, Tag> extends Rpc.Rpc<
infer _Tag,
infer _Payload,
infer _Success,
infer _Error,
infer _Middleware
>
? [_Success] extends [RpcSchema.Stream<infer _A, infer _E>]
? AsMailbox extends true
? Effect.Effect<
Mailbox.ReadonlyMailbox<_A["Type"], _E["Type"] | _Error["Type"] | E>,
never,
Scope.Scope | _Payload["Context"] | _Success["Context"] | _Error["Context"]
>
: Stream.Stream<
_A["Type"],
_E["Type"] | _Error["Type"] | E,
_Payload["Context"] | _Success["Context"] | _Error["Context"]
>
: Effect.Effect<
Discard extends true ? void : _Success["Type"],
Discard extends true ? E : _Error["Type"] | E,
_Payload["Context"] | _Success["Context"] | _Error["Context"]
>
: never
Since v1.0.0
make
Signature
declare const make: <Rpcs extends Rpc.Any, const Flatten extends boolean = false>(
group: RpcGroup.RpcGroup<Rpcs>,
options?:
| {
readonly spanPrefix?: string | undefined
readonly spanAttributes?: Record<string, unknown> | undefined
readonly generateRequestId?: (() => RequestId) | undefined
readonly disableTracing?: boolean | undefined
readonly flatten?: Flatten | undefined
}
| undefined
) => Effect.Effect<
Flatten extends true ? RpcClient.Flat<Rpcs> : RpcClient<Rpcs>,
never,
Protocol | Rpc.MiddlewareClient<Rpcs> | Scope.Scope
>
Since v1.0.0
makeNoSerialization
Signature
declare const makeNoSerialization: <Rpcs extends Rpc.Any, E, const Flatten extends boolean = false>(
group: RpcGroup.RpcGroup<Rpcs>,
options: {
readonly onFromClient: (options: {
readonly message: FromClient<Rpcs>
readonly context: Context.Context<never>
readonly discard: boolean
}) => Effect.Effect<void, E>
readonly supportsAck?: boolean | undefined
readonly spanPrefix?: string | undefined
readonly spanAttributes?: Record<string, unknown> | undefined
readonly generateRequestId?: (() => RequestId) | undefined
readonly disableTracing?: boolean | undefined
readonly flatten?: Flatten | undefined
}
) => Effect.Effect<
{
readonly client: Flatten extends true ? RpcClient.Flat<Rpcs, E> : RpcClient<Rpcs, E>
readonly write: (message: FromServer<Rpcs>) => Effect.Effect<void>
},
never,
Scope.Scope | Rpc.MiddlewareClient<Rpcs>
>
Since v1.0.0
headers
currentHeaders
Signature
declare const currentHeaders: FiberRef.FiberRef<Headers.Headers>
Since v1.0.0
withHeaders
Signature
declare const withHeaders: {
(headers: Headers.Input): <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>
<A, E, R>(effect: Effect.Effect<A, E, R>, headers: Headers.Input): Effect.Effect<A, E, R>
}
Since v1.0.0
withHeadersEffect
Signature
declare const withHeadersEffect: {
<E2, R2>(
headers: Effect.Effect<Headers.Input, E2, R2>
): <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E | E2, R | R2>
<A, E, R, E2, R2>(
effect: Effect.Effect<A, E, R>,
headers: Effect.Effect<Headers.Input, E2, R2>
): Effect.Effect<A, E | E2, R | R2>
}
Since v1.0.0
protocol
Protocol (class)
Signature
declare class Protocol
Since v1.0.0
layerProtocolHttp
Signature
declare const layerProtocolHttp: (options: {
readonly url: string
readonly transformClient?: <E, R>(client: HttpClient.HttpClient.With<E, R>) => HttpClient.HttpClient.With<E, R>
}) => Layer.Layer<Protocol, never, RpcSerialization.RpcSerialization | HttpClient.HttpClient>
Since v1.0.0
layerProtocolSocket
Signature
declare const layerProtocolSocket: (options?: {
readonly retryTransientErrors?: boolean | undefined
}) => Layer.Layer<Protocol, never, Socket.Socket | RpcSerialization.RpcSerialization>
Since v1.0.0
layerProtocolWorker
Signature
declare const layerProtocolWorker: (
options:
| {
readonly size: number
readonly concurrency?: number | undefined
readonly targetUtilization?: number | undefined
}
| {
readonly minSize: number
readonly maxSize: number
readonly concurrency?: number | undefined
readonly targetUtilization?: number | undefined
readonly timeToLive: Duration.DurationInput
}
) => Layer.Layer<Protocol, WorkerError, Worker.PlatformWorker | Worker.Spawner>
Since v1.0.0
makeProtocolHttp
Signature
declare const makeProtocolHttp: (
client: HttpClient.HttpClient
) => Effect.Effect<Protocol["Type"], never, RpcSerialization.RpcSerialization>
Since v1.0.0
makeProtocolSocket
Signature
declare const makeProtocolSocket: (options?: {
readonly retryTransientErrors?: boolean | undefined
}) => Effect.Effect<Protocol["Type"], never, Scope.Scope | RpcSerialization.RpcSerialization | Socket.Socket>
Since v1.0.0
makeProtocolWorker
Signature
declare const makeProtocolWorker: (
options:
| {
readonly size: number
readonly concurrency?: number | undefined
readonly targetUtilization?: number | undefined
}
| {
readonly minSize: number
readonly maxSize: number
readonly concurrency?: number | undefined
readonly targetUtilization?: number | undefined
readonly timeToLive: Duration.DurationInput
}
) => Effect.Effect<Protocol["Type"], WorkerError, Scope.Scope | Worker.PlatformWorker | Worker.Spawner>
Since v1.0.0