Rpc overview
Added in v1.0.0
Table of contents
constructors
effect
Signature
export declare const effect: <Req extends Schema.TaggedRequest.All, R>(
schema: Schema.Schema<Req, any, unknown>,
handler: (request: Req) => Effect.Effect<EffectRequest.Request.Success<Req>, EffectRequest.Request.Error<Req>, R>
) => Rpc<Req, R>
Added in v1.0.0
stream
Signature
export declare const stream: <Req extends StreamRequest.Any, R>(
schema: Schema.Schema<Req, any, unknown>,
handler: (
request: Req
) => Stream.Stream<
Req extends Schema.WithResult<infer A, infer _I, infer _E, infer _EI, infer _R> ? A : never,
Req extends Schema.WithResult<infer _A, infer _I, infer E, infer _EI, infer _R> ? E : never,
R
>
) => Rpc<Req, R>
Added in v1.0.0
context
provideService
Signature
export declare const provideService: {
<I, S>(
tag: Context.Tag<I, S>,
service: S
): <Req extends Schema.TaggedRequest.All, R>(self: Rpc<Req, R>) => Rpc<Req, Exclude<R, I>>
<Req extends Schema.TaggedRequest.All, R, I, S>(
self: Rpc<Req, R>,
tag: Context.Tag<I, S>,
service: S
): Rpc<Req, Exclude<R, I>>
}
Added in v1.0.0
provideServiceEffect
Signature
export declare const provideServiceEffect: {
<I, S, E, R2>(
tag: Context.Tag<I, S>,
effect: Effect.Effect<S, E, R2>
): <Req extends Schema.TaggedRequest.All, R>(self: Rpc<Req, R>) => Rpc<Req, Exclude<R, I> | R2>
<Req extends Schema.TaggedRequest.All, R, I, S, E, R2>(
self: Rpc<Req, R>,
tag: Context.Tag<I, S>,
effect: Effect.Effect<S, E, R2>
): Rpc<Req, Exclude<R, I> | R2>
}
Added in v1.0.0
headers
annotateHeaders
Signature
export declare const annotateHeaders: {
(headers: Headers.Input): <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>
<A, E, R>(self: Effect.Effect<A, E, R>, headers: Headers.Input): Effect.Effect<A, E, R>
}
Added in v1.0.0
currentHeaders
Signature
export declare const currentHeaders: FiberRef.FiberRef<Headers.Headers>
Added in v1.0.0
schemaHeaders
Signature
export declare const schemaHeaders: <R, I extends Record.ReadonlyRecord<string, string | undefined>, A>(
schema: Schema.Schema<R, I, A>
) => Effect.Effect<R, ParseResult.ParseError, A>
Added in v1.0.0
models
Request (interface)
Signature
export interface Request<A extends Schema.TaggedRequest.All>
extends EffectRequest.Request<EffectRequest.Request.Success<A>, EffectRequest.Request.Error<A>>,
PrimaryKey.PrimaryKey,
Schema.WithResult<
Schema.WithResult.Context<A>,
Schema.Schema.Encoded<A[typeof Schema.symbolWithResult]["failure"]>,
Schema.Schema.Type<A[typeof Schema.symbolWithResult]["failure"]>,
Schema.Schema.Encoded<A[typeof Schema.symbolWithResult]["success"]>,
Schema.Schema.Type<A[typeof Schema.symbolWithResult]["success"]>
> {
readonly request: A
readonly traceId: string
readonly spanId: string
readonly sampled: boolean
readonly headers: Headers.Headers
}
Added in v1.0.0
RequestFrom (interface)
Signature
export interface RequestFrom<A> {
readonly request: A
readonly traceId: string
readonly spanId: string
readonly sampled: boolean
readonly headers: Record<string, string>
}
Added in v1.0.0
Rpc (type alias)
Signature
export type Rpc<Req extends Schema.TaggedRequest.All, R> = RpcEffect<Req, R> | RpcStream<Req, R>
Added in v1.0.0
Rpc (namespace)
Added in v1.0.0
Proto (interface)
Signature
export interface Proto<Req extends Schema.TaggedRequest.All> extends Pipeable {
readonly [TypeId]: TypeId
readonly _tag: string
readonly schema: Schema.Schema<Req, any, unknown>
}
Added in v1.0.0
Context (type alias)
Signature
export type Context<A extends Rpc<any, any>> =
A extends Rpc<infer Req, infer R> ? R | Schema.SerializableWithResult.Context<Req> : never
Added in v1.0.0
Request (type alias)
Signature
export type Request<A extends Rpc<any, any>> = Schema.Schema.Type<A["schema"]>
Added in v1.0.0
Result (type alias)
Signature
export type Result<A extends Schema.TaggedRequest.All, R = never> = StreamRequestTypeId extends keyof A
? EffectRequest.Request.Success<A>
: Effect.Effect<EffectRequest.Request.Success<A>, EffectRequest.Request.Error<A>, R>
Added in v1.0.0
ResultUndecoded (type alias)
Signature
export type ResultUndecoded<A extends Schema.TaggedRequest.All, R = never> =
A extends Schema.WithResult<infer _A, infer I, infer E, infer _EI, infer _R>
? StreamRequestTypeId extends keyof A
? Stream.Stream<I, E, R>
: Effect.Effect<I, E, R>
: never
Added in v1.0.0
RpcEffect (interface)
Signature
export interface RpcEffect<Req extends Schema.TaggedRequest.All, R> extends Rpc.Proto<Req> {
readonly _tag: "Effect"
readonly handler: (
request: Req
) => Effect.Effect<EffectRequest.Request.Success<Req>, EffectRequest.Request.Error<Req>, R>
}
Added in v1.0.0
RpcStream (interface)
Signature
export interface RpcStream<Req extends Schema.TaggedRequest.All, R> extends Rpc.Proto<Req> {
readonly _tag: "Stream"
readonly handler: (
request: Req
) => Stream.Stream<
Req extends Schema.WithResult<infer A, infer _I, infer _E, infer _EI, infer _R> ? A : never,
Req extends Schema.WithResult<infer _A, infer _I, infer E, infer _EI, infer _R> ? E : never,
R
>
}
Added in v1.0.0
refinements
isRpc
Signature
export declare const isRpc: (u: unknown) => u is Rpc<any, any>
Added in v1.0.0
requests
call
Signature
export declare const call: <
A extends Schema.TaggedRequest.All,
R extends
| RequestResolver.RequestResolver<Request<A>>
| Effect.Effect<RequestResolver.RequestResolver<Request<A>>, never, any>
>(
req: A,
resolver: R,
options?: { readonly spanPrefix?: string }
) => R extends Effect.Effect<infer _A, infer _E, infer R> ? Rpc.Result<A, R> : Rpc.Result<A>
Added in v1.0.0
request
Signature
export declare const request: <A extends Schema.TaggedRequest.All>(
request: A,
options?: { readonly spanPrefix?: string }
) => Effect.Effect<Request<A>, never, Scope>
Added in v1.0.0
schemas
RequestSchema
Signature
export declare const RequestSchema: <A, I, R>(
schema: Schema.Schema<A, I, R>
) => Schema.Schema<RequestFrom<A>, RequestFrom<I>, R>
Added in v1.0.0
StreamRequest
Signature
export declare const StreamRequest: <Self>() => <
Tag extends string,
E,
IE,
RE,
A,
IA,
RA,
Payload extends Schema.Struct.Fields
>(
tag: Tag,
options: {
readonly failure: Schema.Schema<E, IE, RE>
readonly success: Schema.Schema<A, IA, RA>
readonly payload: Payload
}
) => StreamRequestConstructor<
Tag,
Self,
Schema.Schema.Context<Payload[keyof Payload]>,
Types.Simplify<Schema.Struct.Encoded<Payload>>,
Types.Simplify<Schema.Struct.Type<Payload>>,
RE | RA,
IE,
E,
IA,
A
>
Added in v1.0.0
StreamRequest (interface)
Signature
export interface StreamRequest<Tag extends string, SR, SI, S, RR, EI, E, AI, A>
extends EffectRequest.Request<Stream.Stream<A, E, never>>,
Schema.SerializableWithResult<S, SI, SR, A, AI, E, EI, RR> {
readonly [StreamRequestTypeId]: StreamRequestTypeId
readonly _tag: Tag
}
Added in v1.0.0
StreamRequest (namespace)
Added in v1.0.0
Any (type alias)
Signature
export type Any =
| StreamRequest<string, any, any, any, any, any, any, any, any>
| StreamRequest<string, any, any, any, any, never, never, any, any>
Added in v1.0.0
StreamRequestConstructor (interface)
Signature
export interface StreamRequestConstructor<Tag extends string, Self, R, IS, S, RR, IE, E, IA, A>
extends Schema.Schema<Self, Types.Simplify<IS & { readonly _tag: Tag }>, R> {
new (
props: Types.Equals<S, {}> extends true ? void : S,
disableValidation?: boolean
): StreamRequest<Tag, R, IS & { readonly _tag: Tag }, Self, RR, IE, E, IA, A> & S
}
Added in v1.0.0
type ids
StreamRequestTypeId
Signature
export declare const StreamRequestTypeId: typeof StreamRequestTypeId
Added in v1.0.0
StreamRequestTypeId (type alias)
Signature
export type StreamRequestTypeId = typeof StreamRequestTypeId
Added in v1.0.0
TypeId
Signature
export declare const TypeId: typeof TypeId
Added in v1.0.0
TypeId (type alias)
Signature
export type TypeId = typeof TypeId
Added in v1.0.0