<
Self,
F extends QueueItemFields = QueueItemFields,
R = never,
RR = never,
Success extends Schema.Top = Schema.Void,
Error extends Schema.Top = Schema.Never
>(
tag: QueueTagFor<Self, F, Success, Error>,
config: QueueVerbConfig<F, QueueErrorValueOf<Error>, R, RR, Success>
): Layer.Layer<HandlerContextOf<QueueInstanceSpec<F>>, never, R | RR>
<
Self,
F extends PriorityItemFields = PriorityItemFields,
E = never,
R = never,
RR = never
>(
tag: HyperlinkTag<Self, PriorityInstanceSpec<F>>,
config: PriorityLayerConfig<Schema.Struct<F>["Type"], E, R, RR>
): Layer.Layer<HandlerContextOf<PriorityInstanceSpec<F>>, never, R | RR>Serve this queue remotely (served-only) — run the worker / refill / persist
engine behind the tag, mount its RPC handlers, and register into Hyperlink.servedHyperServicesLayer,
without granting the local instance (no yield* Tag in the serving process). The engine's worker
requirement R is preserved, so a per-HyperService Layer.provide discharges it in isolation — the
queue's counterpart to Hyperlink.serveRemote.
Reach for this (with Node.httpServer) for a pure gateway/edge that exposes the queue for remote clients but never consumes it locally; use serve when the serving node also drives it.
Node.httpServer([
WorkPool.serveRemote(RosterImportQueue, rosterCfg).pipe(Layer.provide(emptyHookSource)),
WorkPool.serveRemote(MediaImportQueue, mediaCfg).pipe(Layer.provide(emptyHookSource)),
]).pipe(Layer.provide(NodeHttpServer.layer(() => createServer(), { port })));export function function serveRemote<Self, F extends QueueItemFields = QueueItemFields, R = never, RR = never, Success extends Schema.Top = Schema.Void, Error extends Schema.Top = Schema.Never>(tag: QueueTagFor<Self, F, Success, Error>, config: QueueVerbConfig<F, QueueErrorValueOf<Error>, R, RR, Success>): Layer.Layer<HandlerContextOf<QueueInstanceSpec<F>>, never, R | RR> (+1 overload)Serve this queue remotely (served-only) — run the worker / refill / persist
engine behind the tag, mount its RPC handlers, and register into
Hyperlink.servedHyperServicesLayer
,
without granting the local instance (no yield* Tag in the serving process). The engine's worker
requirement R is preserved, so a per-HyperService Layer.provide discharges it in isolation — the
queue's counterpart to
Hyperlink.serveRemote
.
Reach for this (with
Node.httpServer
) for a pure gateway/edge that exposes the queue for
remote clients but never consumes it locally; use
serve
when the serving node also drives it.
Node.httpServer([
WorkPool.serveRemote(RosterImportQueue, rosterCfg).pipe(Layer.provide(emptyHookSource)),
WorkPool.serveRemote(MediaImportQueue, mediaCfg).pipe(Layer.provide(emptyHookSource)),
]).pipe(Layer.provide(NodeHttpServer.layer(() => createServer(), { port })));
serveRemote<
function (type parameter) Self in serveRemote<Self, F extends QueueItemFields = QueueItemFields, R = never, RR = never, Success extends Schema.Top = Schema.Void, Error extends Schema.Top = Schema.Never>(tag: QueueTagFor<Self, F, Success, Error>, config: QueueVerbConfig<F, QueueErrorValueOf<Error>, R, RR, Success>): Layer.Layer<HandlerContextOf<QueueInstanceSpec<F>>, never, R | RR>Self,
function (type parameter) F in serveRemote<Self, F extends QueueItemFields = QueueItemFields, R = never, RR = never, Success extends Schema.Top = Schema.Void, Error extends Schema.Top = Schema.Never>(tag: QueueTagFor<Self, F, Success, Error>, config: QueueVerbConfig<F, QueueErrorValueOf<Error>, R, RR, Success>): Layer.Layer<HandlerContextOf<QueueInstanceSpec<F>>, never, R | RR>F extends type QueueItemFields = {
[x: string]: Schema.Codec<
unknown,
unknown,
never,
never
>
}
The item-schema constraint shared by
layer
/
serve
/
serveRemote
.
QueueItemFields = type QueueItemFields = {
[x: string]: Schema.Codec<
unknown,
unknown,
never,
never
>
}
The item-schema constraint shared by
layer
/
serve
/
serveRemote
.
QueueItemFields,
function (type parameter) R in serveRemote<Self, F extends QueueItemFields = QueueItemFields, R = never, RR = never, Success extends Schema.Top = Schema.Void, Error extends Schema.Top = Schema.Never>(tag: QueueTagFor<Self, F, Success, Error>, config: QueueVerbConfig<F, QueueErrorValueOf<Error>, R, RR, Success>): Layer.Layer<HandlerContextOf<QueueInstanceSpec<F>>, never, R | RR>R = never,
function (type parameter) RR in serveRemote<Self, F extends QueueItemFields = QueueItemFields, R = never, RR = never, Success extends Schema.Top = Schema.Void, Error extends Schema.Top = Schema.Never>(tag: QueueTagFor<Self, F, Success, Error>, config: QueueVerbConfig<F, QueueErrorValueOf<Error>, R, RR, Success>): Layer.Layer<HandlerContextOf<QueueInstanceSpec<F>>, never, R | RR>RR = never,
function (type parameter) Success in serveRemote<Self, F extends QueueItemFields = QueueItemFields, R = never, RR = never, Success extends Schema.Top = Schema.Void, Error extends Schema.Top = Schema.Never>(tag: QueueTagFor<Self, F, Success, Error>, config: QueueVerbConfig<F, QueueErrorValueOf<Error>, R, RR, Success>): Layer.Layer<HandlerContextOf<QueueInstanceSpec<F>>, never, R | RR>Success extends import SchemaSchema.Top = typeof import SchemaSchema.const Void: Voidconst Void: {
Rebuild: Rebuild;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Schema.Annotations.Bottom<void, readonly []>) => Schema.Void;
annotateKey: (annotations: Schema.Annotations.Key<void>) => Schema.Void;
check: (checks_0: Check<void>, ...checks: Array<Check<void>>) => Schema.Void;
rebuild: (ast: Void) => Schema.Void;
make: (input: void, options?: MakeOptions) => void;
makeOption: (input: void, options?: MakeOptions) => Option_.Option<void>;
makeEffect: (input: void, options?: MakeOptions) => Effect.Effect<void, SchemaError, never>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
Type-level representation of
Void
.
Schema for a TypeScript void return value.
When to use
Use when you need to model the return value of a function, RPC, or endpoint
whose result is intentionally ignored.
Details
Runtime parsing accepts any present value and discards it, producing
undefined. The public decoded and encoded TypeScript representation remains
void, so typed construction, decoding, and encoding APIs are still modeled
as void.
Void,
function (type parameter) Error in serveRemote<Self, F extends QueueItemFields = QueueItemFields, R = never, RR = never, Success extends Schema.Top = Schema.Void, Error extends Schema.Top = Schema.Never>(tag: QueueTagFor<Self, F, Success, Error>, config: QueueVerbConfig<F, QueueErrorValueOf<Error>, R, RR, Success>): Layer.Layer<HandlerContextOf<QueueInstanceSpec<F>>, never, R | RR>Error extends import SchemaSchema.Top = typeof import SchemaSchema.const Never: Neverconst Never: {
Rebuild: Rebuild;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Schema.Annotations.Bottom<never, readonly []>) => Schema.Never;
annotateKey: (annotations: Schema.Annotations.Key<never>) => Schema.Never;
check: (checks_0: Check<never>, ...checks: Array<Check<never>>) => Schema.Never;
rebuild: (ast: Never) => Schema.Never;
make: (input: never, options?: MakeOptions) => never;
makeOption: (input: never, options?: MakeOptions) => Option_.Option<never>;
makeEffect: (input: never, options?: MakeOptions) => Effect.Effect<never, SchemaError, never>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
Type-level representation of
Never
.
Schema for the never type. Always fails validation — no value satisfies it.
Never,
>(
tag: QueueTagFor<Self, F, Success, Error>tag: type QueueTagFor<Self, F extends QueueItemFields, Success extends Schema.Top, Error extends Schema.Top> = Hyperlink.HyperlinkTag<Self, {
add: Hyperlink.Method<Schema.Union<readonly [Schema.Struct<F>, Schema.$Array<Schema.Struct<F>>]>, Schema.Void, Schema.Never, false, Hyperlink.MethodAnnotations & {
description: string;
}, {
(item: PrettifyPayload<Schema.Struct.View<F, "Type", Schema.Struct.TypeOptionalKeys<F>, Schema.Struct.TypeMutableKeys<F>>>): Effect.Effect<void>;
(items: readonly PrettifyPayload<Schema.Struct.View<F, "Type", Schema.Struct.TypeOptionalKeys<F>, Schema.Struct.TypeMutableKeys<...>>>[]): Effect.Effect<void>;
(itemOrItems: PrettifyPayload<...> | readonly PrettifyPayload<...>[]): Effect.Effect<void>;
}>;
... 16 more ...;
metrics: {
...;
};
}, {
...;
}> & QueueSuccessCarrier<...> & QueueErrorCarrier<...> & QueueItemSchemaCarrier<...>
The tag: param shape shared by every queue verb (
buildQueueImpl
/
layer
/
serve
/
serveRemote
/
configure
): the instance's
HyperlinkTag
over
the threaded
QueueInstanceSpec
<F, Success, Error> (so events carries the real
Cause<Error> / Completed.success, matching
materializeQueueTag
), plus the
worker-success/error carriers. Both are needed: the spec sits at HyperlinkTag's invariant
Shape position (unreliable for inference), so the covariant carriers give the verbs a stable
surface to infer Success/Error from the passed tag.
QueueTagFor<function (type parameter) Self in serveRemote<Self, F extends QueueItemFields = QueueItemFields, R = never, RR = never, Success extends Schema.Top = Schema.Void, Error extends Schema.Top = Schema.Never>(tag: QueueTagFor<Self, F, Success, Error>, config: QueueVerbConfig<F, QueueErrorValueOf<Error>, R, RR, Success>): Layer.Layer<HandlerContextOf<QueueInstanceSpec<F>>, never, R | RR>Self, function (type parameter) F in serveRemote<Self, F extends QueueItemFields = QueueItemFields, R = never, RR = never, Success extends Schema.Top = Schema.Void, Error extends Schema.Top = Schema.Never>(tag: QueueTagFor<Self, F, Success, Error>, config: QueueVerbConfig<F, QueueErrorValueOf<Error>, R, RR, Success>): Layer.Layer<HandlerContextOf<QueueInstanceSpec<F>>, never, R | RR>F, function (type parameter) Success in serveRemote<Self, F extends QueueItemFields = QueueItemFields, R = never, RR = never, Success extends Schema.Top = Schema.Void, Error extends Schema.Top = Schema.Never>(tag: QueueTagFor<Self, F, Success, Error>, config: QueueVerbConfig<F, QueueErrorValueOf<Error>, R, RR, Success>): Layer.Layer<HandlerContextOf<QueueInstanceSpec<F>>, never, R | RR>Success, function (type parameter) Error in serveRemote<Self, F extends QueueItemFields = QueueItemFields, R = never, RR = never, Success extends Schema.Top = Schema.Void, Error extends Schema.Top = Schema.Never>(tag: QueueTagFor<Self, F, Success, Error>, config: QueueVerbConfig<F, QueueErrorValueOf<Error>, R, RR, Success>): Layer.Layer<HandlerContextOf<QueueInstanceSpec<F>>, never, R | RR>Error>,
config: QueueVerbConfig<
F,
QueueErrorValueOf<Error>,
R,
RR,
Success
>
config: type QueueVerbConfig<F extends QueueItemFields, E, R, RR, Success extends Schema.Top> = Omit<WorkPoolConfigWithItemSchema<Schema.Struct.View<F, "Type", Schema.Struct.TypeOptionalKeys<F>, Schema.Struct.TypeMutableKeys<F>>, E, R, QueueSuccessValueOf<Success>>, "itemSchema" | "refill"> & {
readonly refill?: {
readonly onStart?: boolean;
readonly onDrained?: boolean;
readonly load: (queue: EngineQueueHandle<Schema.Struct.View<F, "Type", Schema.Struct.TypeOptionalKeys<F>, Schema.Struct.TypeMutableKeys<F>>, E, QueueEnqueueErrors, never, QueueSuccessValueOf<...>>) => Effect.Effect<...>;
} | undefined;
}
The worker-config: param shape shared by every queue verb —
QueueLayerConfig
with the
instance item type + worker-success value recovered from F / Success.
QueueVerbConfig<function (type parameter) F in serveRemote<Self, F extends QueueItemFields = QueueItemFields, R = never, RR = never, Success extends Schema.Top = Schema.Void, Error extends Schema.Top = Schema.Never>(tag: QueueTagFor<Self, F, Success, Error>, config: QueueVerbConfig<F, QueueErrorValueOf<Error>, R, RR, Success>): Layer.Layer<HandlerContextOf<QueueInstanceSpec<F>>, never, R | RR>F, type QueueErrorValueOf<
Error extends Schema.Top
> = Error["Type"]
The worker error value type (E) carried on a queue instance spec's Error wire schema — the
decoded type of the tag's error slot (default never). The layer/serve config's worker failure
channel is constrained to this.
QueueErrorValueOf<function (type parameter) Error in serveRemote<Self, F extends QueueItemFields = QueueItemFields, R = never, RR = never, Success extends Schema.Top = Schema.Void, Error extends Schema.Top = Schema.Never>(tag: QueueTagFor<Self, F, Success, Error>, config: QueueVerbConfig<F, QueueErrorValueOf<Error>, R, RR, Success>): Layer.Layer<HandlerContextOf<QueueInstanceSpec<F>>, never, R | RR>Error>, function (type parameter) R in serveRemote<Self, F extends QueueItemFields = QueueItemFields, R = never, RR = never, Success extends Schema.Top = Schema.Void, Error extends Schema.Top = Schema.Never>(tag: QueueTagFor<Self, F, Success, Error>, config: QueueVerbConfig<F, QueueErrorValueOf<Error>, R, RR, Success>): Layer.Layer<HandlerContextOf<QueueInstanceSpec<F>>, never, R | RR>R, function (type parameter) RR in serveRemote<Self, F extends QueueItemFields = QueueItemFields, R = never, RR = never, Success extends Schema.Top = Schema.Void, Error extends Schema.Top = Schema.Never>(tag: QueueTagFor<Self, F, Success, Error>, config: QueueVerbConfig<F, QueueErrorValueOf<Error>, R, RR, Success>): Layer.Layer<HandlerContextOf<QueueInstanceSpec<F>>, never, R | RR>RR, function (type parameter) Success in serveRemote<Self, F extends QueueItemFields = QueueItemFields, R = never, RR = never, Success extends Schema.Top = Schema.Void, Error extends Schema.Top = Schema.Never>(tag: QueueTagFor<Self, F, Success, Error>, config: QueueVerbConfig<F, QueueErrorValueOf<Error>, R, RR, Success>): Layer.Layer<HandlerContextOf<QueueInstanceSpec<F>>, never, R | RR>Success>,
): import LayerLayer.interface Layer<in ROut, out E = never, out RIn = never>A Layer describes how to build one or more services for dependency injection.
When to use
Use to model construction of application services for dependency injection,
especially when services have dependencies, can fail during construction, or
need scoped setup and release.
Details
A Layer<ROut, E, RIn> represents ROut as the services this layer
provides, E as the possible errors during layer construction, and RIn as
the services this layer requires as dependencies.
Layer<type HandlerContextOf<S extends Spec> = RpcUnionOf<S, ""> extends Rpc<infer _Tag extends string, infer _Payload extends Schema.Top, infer _Success extends Schema.Top, infer _Error extends Schema.Top, infer _Middleware extends AnyService, infer _Requires> ? Handler<_Tag> : neverThe context a server layer for a
Spec
provides: the handler for every method.
Used to pin the server layers' output type so their requirement channel stays
never — RpcGroup's own ToHandlerFn defaults that channel to any, so without
this the inferred server layer would re-leak any into anything that consumes it.
HandlerContextOf<type QueueInstanceSpec<F extends Schema.Struct.Fields, Success extends Schema.Top = Schema.Void, Error extends Schema.Top = Schema.Never> = {
add: Hyperlink.Method<Schema.Union<readonly [Schema.Struct<F>, Schema.$Array<Schema.Struct<F>>]>, Schema.Void, Schema.Never, false, Hyperlink.MethodAnnotations & {
description: string;
}, {
(item: PrettifyPayload<Schema.Struct.View<F, "Type", Schema.Struct.TypeOptionalKeys<F>, Schema.Struct.TypeMutableKeys<F>>>): Effect.Effect<void>;
(items: readonly PrettifyPayload<Schema.Struct.View<F, "Type", Schema.Struct.TypeOptionalKeys<F>, Schema.Struct.TypeMutableKeys<F>>>[]): Effect.Effect<void>;
(itemOrItems: PrettifyPayload<...> | readonly PrettifyPayload<...>[]): Effect.Effect<void>;
}>;
... 16 more ...;
metrics: {
...;
};
}
The spec of a queue instance whose item is Schema.Struct<F> — control surface + data plane.
Success/Error are the tag's declared wire slots (default Void/Never), threaded so the
contract's events carry the real Cause<E> / Completed.success rather than erasing to the
loose default.
QueueInstanceSpec<function (type parameter) F in serveRemote<Self, F extends QueueItemFields = QueueItemFields, R = never, RR = never, Success extends Schema.Top = Schema.Void, Error extends Schema.Top = Schema.Never>(tag: QueueTagFor<Self, F, Success, Error>, config: QueueVerbConfig<F, QueueErrorValueOf<Error>, R, RR, Success>): Layer.Layer<HandlerContextOf<QueueInstanceSpec<F>>, never, R | RR>F>>, never, function (type parameter) R in serveRemote<Self, F extends QueueItemFields = QueueItemFields, R = never, RR = never, Success extends Schema.Top = Schema.Void, Error extends Schema.Top = Schema.Never>(tag: QueueTagFor<Self, F, Success, Error>, config: QueueVerbConfig<F, QueueErrorValueOf<Error>, R, RR, Success>): Layer.Layer<HandlerContextOf<QueueInstanceSpec<F>>, never, R | RR>R | function (type parameter) RR in serveRemote<Self, F extends QueueItemFields = QueueItemFields, R = never, RR = never, Success extends Schema.Top = Schema.Void, Error extends Schema.Top = Schema.Never>(tag: QueueTagFor<Self, F, Success, Error>, config: QueueVerbConfig<F, QueueErrorValueOf<Error>, R, RR, Success>): Layer.Layer<HandlerContextOf<QueueInstanceSpec<F>>, never, R | RR>RR>;
export function function serveRemote<Self, F extends PriorityItemFields = PriorityItemFields, E = never, R = never, RR = never>(tag: HyperlinkTag<Self, PriorityInstanceSpec<F>>, config: PriorityLayerConfig<Schema.Struct<F>["Type"], E, R, RR>): Layer.Layer<HandlerContextOf<PriorityInstanceSpec<F>>, never, R | RR> (+1 overload)Serve this queue remotely (served-only) — run the worker / refill / persist
engine behind the tag, mount its RPC handlers, and register into
Hyperlink.servedHyperServicesLayer
,
without granting the local instance (no yield* Tag in the serving process). The engine's worker
requirement R is preserved, so a per-HyperService Layer.provide discharges it in isolation — the
queue's counterpart to
Hyperlink.serveRemote
.
Reach for this (with
Node.httpServer
) for a pure gateway/edge that exposes the queue for
remote clients but never consumes it locally; use
serve
when the serving node also drives it.
Node.httpServer([
WorkPool.serveRemote(RosterImportQueue, rosterCfg).pipe(Layer.provide(emptyHookSource)),
WorkPool.serveRemote(MediaImportQueue, mediaCfg).pipe(Layer.provide(emptyHookSource)),
]).pipe(Layer.provide(NodeHttpServer.layer(() => createServer(), { port })));
serveRemote<
function (type parameter) Self in serveRemote<Self, F extends PriorityItemFields = PriorityItemFields, E = never, R = never, RR = never>(tag: HyperlinkTag<Self, PriorityInstanceSpec<F>>, config: PriorityLayerConfig<Schema.Struct<F>["Type"], E, R, RR>): Layer.Layer<HandlerContextOf<PriorityInstanceSpec<F>>, never, R | RR>Self,
function (type parameter) F in serveRemote<Self, F extends PriorityItemFields = PriorityItemFields, E = never, R = never, RR = never>(tag: HyperlinkTag<Self, PriorityInstanceSpec<F>>, config: PriorityLayerConfig<Schema.Struct<F>["Type"], E, R, RR>): Layer.Layer<HandlerContextOf<PriorityInstanceSpec<F>>, never, R | RR>F extends type PriorityItemFields = {
[x: string]: Schema.Codec<
unknown,
unknown,
never,
never
>
}
PriorityItemFields = type PriorityItemFields = {
[x: string]: Schema.Codec<
unknown,
unknown,
never,
never
>
}
PriorityItemFields,
function (type parameter) E in serveRemote<Self, F extends PriorityItemFields = PriorityItemFields, E = never, R = never, RR = never>(tag: HyperlinkTag<Self, PriorityInstanceSpec<F>>, config: PriorityLayerConfig<Schema.Struct<F>["Type"], E, R, RR>): Layer.Layer<HandlerContextOf<PriorityInstanceSpec<F>>, never, R | RR>E = never,
function (type parameter) R in serveRemote<Self, F extends PriorityItemFields = PriorityItemFields, E = never, R = never, RR = never>(tag: HyperlinkTag<Self, PriorityInstanceSpec<F>>, config: PriorityLayerConfig<Schema.Struct<F>["Type"], E, R, RR>): Layer.Layer<HandlerContextOf<PriorityInstanceSpec<F>>, never, R | RR>R = never,
function (type parameter) RR in serveRemote<Self, F extends PriorityItemFields = PriorityItemFields, E = never, R = never, RR = never>(tag: HyperlinkTag<Self, PriorityInstanceSpec<F>>, config: PriorityLayerConfig<Schema.Struct<F>["Type"], E, R, RR>): Layer.Layer<HandlerContextOf<PriorityInstanceSpec<F>>, never, R | RR>RR = never,
>(
tag: HyperlinkTag<
Self,
PriorityInstanceSpec<F>
>
(parameter) tag: {
key: Identifier;
Service: {
enqueue: (payload: ReadonlyArray<{ attempts: number; item: Schema.Struct.View<F, 'Type', Schema.Struct.TypeOptionalKeys<F>, Schema.Struct.TypeMutableKeys<F>>; entryId: string; priority: 'high' | 'normal' | 'low'; timestamps: { readonly enqueuedAt: …;
release: (payload: { options?: { readonly releaseId?: string | undefined; readonly attributes?: { readonly [x: string]: JsonValue } | undefined; readonly scope?: 'pendingOnly' | undefined } | undefined }) => Effect.Effect<ReadonlyArray<{ readonly a…;
releaseEncoded: (payload: { options?: { readonly releaseId?: string | undefined; readonly attributes?: { readonly [x: string]: JsonValue } | undefined; readonly scope?: 'pendingOnly' | undefined } | undefined }) => Effect.Effect<ReadonlyArray<{ readonly a…;
deadLetter: (payload: { selector: { readonly key?: string | undefined; readonly item?: Schema.Struct.View<F, 'Type', Schema.Struct.TypeOptionalKeys<F>, Schema.Struct.TypeMutableKeys<F>> | undefined; readonly entryId?: string | undefined }; options: { …;
drop: (payload: { selector: { readonly key?: string | undefined; readonly item?: Schema.Struct.View<F, 'Type', Schema.Struct.TypeOptionalKeys<F>, Schema.Struct.TypeMutableKeys<F>> | undefined; readonly entryId?: string | undefined }; options: { …;
events: Stream.Stream<Schema.Struct.ReadonlySide<{ readonly _tag: Schema.tag<'Start'>; readonly key: Schema.String }, 'Type'> | { readonly entries: ReadonlyArray<{ readonly attempts: number; readonly item: Schema.Struct.View<F, 'Type', Schema.Stru…;
status: Hyperlink.Subscribable<Schema.Struct.ReadonlySide<{ readonly sizes: Schema.$Record<Schema.String, Schema.Number>; readonly paused: Schema.Boolean; readonly inFlight: Schema.Number; readonly completed: Schema.Number; readonly phase: Schema.…;
size: Hyperlink.Subscribable<number>;
isEmpty: Hyperlink.Subscribable<boolean>;
start: Effect.Effect<void, never, never>;
pause: Effect.Effect<void, never, never>;
resume: Effect.Effect<void, never, never>;
shutdown: Effect.Effect<void, never, never>;
clear: Effect.Effect<number, never, never>;
metrics: { readonly stream: Stream.Stream<{ readonly inFlight: number; readonly completed: number; readonly avgWaitMillis: { readonly high?: number | undefined; readonly normal?: number | undefined; readonly low?: number | undefined }; readonly win…;
levelSizes: Effect.Effect<ReadonlyArray<number>, never, never>;
add: (arg0: unknown, arg1?: unknown) => Effect.Effect<void, never, never>;
};
description: string | undefined;
of: (this: void, self: { readonly enqueue: (payload: ReadonlyArray<{ attempts: number; item: Schema.Struct.View<F, 'Type', Schema.Struct.TypeOptionalKeys<F>, Schema.Struct.TypeMutableKeys<F>>; entryId: string; priority: 'high' | 'normal' | 'lo…;
context: (self: { readonly enqueue: (payload: ReadonlyArray<{ attempts: number; item: Schema.Struct.View<F, 'Type', Schema.Struct.TypeOptionalKeys<F>, Schema.Struct.TypeMutableKeys<F>>; entryId: string; priority: 'high' | 'normal' | 'low'; timestam…;
use: (f: (service: { readonly enqueue: (payload: ReadonlyArray<{ attempts: number; item: Schema.Struct.View<F, 'Type', Schema.Struct.TypeOptionalKeys<F>, Schema.Struct.TypeMutableKeys<F>>; entryId: string; priority: 'high' | 'normal' | 'low'; t…;
useSync: (f: (service: { readonly enqueue: (payload: ReadonlyArray<{ attempts: number; item: Schema.Struct.View<F, 'Type', Schema.Struct.TypeOptionalKeys<F>, Schema.Struct.TypeMutableKeys<F>>; entryId: string; priority: 'high' | 'normal' | 'low'; t…;
Identifier: Identifier;
stack: string | undefined;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
tag: interface HyperlinkTag<Self, S extends Spec, Svc = Simplify<{ readonly [K in keyof S]: S[K] extends FromLocalMethod<infer M> ? InjectLocal<M, Self> : S[K] extends LocalMethod<infer T> ? LocalEffect<...> : S[K] extends DefaultMethod<...> ? F : S[K] extends { ...; } ? SuccessOf<...> : S[K] extends { ...; } ? Subscribable<...> : S[K] extends { ...; } ? ClientMethod<...> : S[K] extends Spec ? Simplify<...> : never; }>>The type of a HyperService tag carrying spec S — what
Hyperlink.Tag
produces
(and what you extend). Lets a consumer write
<S extends Spec>(tag: HyperlinkTag<Self, S>) and read the spec through named types
(
specOf
/
groupOf
) instead of a Parameters<typeof specOf> workaround.
HyperlinkTag<function (type parameter) Self in serveRemote<Self, F extends PriorityItemFields = PriorityItemFields, E = never, R = never, RR = never>(tag: HyperlinkTag<Self, PriorityInstanceSpec<F>>, config: PriorityLayerConfig<Schema.Struct<F>["Type"], E, R, RR>): Layer.Layer<HandlerContextOf<PriorityInstanceSpec<F>>, never, R | RR>Self, type PriorityInstanceSpec<F extends Schema.Struct.Fields> = Omit<{
add: Hyperlink.Method<Schema.Tuple<readonly [Schema.Union<readonly [Schema.Struct<F>, Schema.$Array<Schema.Struct<F>>]>, Schema.optional<Schema.Schema<string | number>>]>, Schema.Void, Schema.Never, false, Hyperlink.MethodAnnotations & {
readonly callStyle: "pair";
} & {
description: string;
}, Hyperlink.Derive>;
enqueue: Hyperlink.Method<Schema.$Array<Schema.Struct<{
readonly item: Schema.Struct<F>;
readonly entryId: Schema.String;
readonly key: Schema.optional<Schema.String>;
... 7 more ...;
readonly attributes: Schema.optional<...>;
}>>, ... 4 more ..., Hyperlink.Derive>;
... 14 more ...;
metrics: {
...;
};
}, "add"> & {
...;
}
Full priority-queue instance contract for itemSchema F.
PriorityInstanceSpec<function (type parameter) F in serveRemote<Self, F extends PriorityItemFields = PriorityItemFields, E = never, R = never, RR = never>(tag: HyperlinkTag<Self, PriorityInstanceSpec<F>>, config: PriorityLayerConfig<Schema.Struct<F>["Type"], E, R, RR>): Layer.Layer<HandlerContextOf<PriorityInstanceSpec<F>>, never, R | RR>F>>,
config: PriorityLayerConfig<
Schema.Struct<F>["Type"],
E,
R,
RR
>
config: type PriorityLayerConfig<
A,
E,
R,
RR = never
> = Omit<
WorkPoolPriorityConfigWithItemSchema<A, E, R>,
"itemSchema" | "refill" | "name"
> & {
readonly refill?: {
readonly onStart?: boolean
readonly onDrained?: boolean
readonly load: (
queue: WorkPoolPriorityHandle<
A,
E,
QueueEnqueueErrors,
never
>
) => Effect.Effect<void, never, RR>
}
}
Worker/layer config for a toolkit priority queue (tag carries itemSchema).
PriorityLayerConfig<import SchemaSchema.interface Struct<Fields extends Schema.Struct.Fields>Defines a struct schema from a map of field schemas.
Details
Each field value is a schema. Use
optionalKey
or
optional
to
mark fields as optional, and
mutableKey
to mark them as mutable.
The resulting schema's Type is a readonly object type with the fields'
decoded types. The Encoded form mirrors the field schemas' encoded types.
Example (Defining a basic struct)
import { Schema } from "effect"
const Person = Schema.Struct({
name: Schema.String,
age: Schema.Number,
email: Schema.optionalKey(Schema.String)
})
// { readonly name: string; readonly age: number; readonly email?: string }
type Person = typeof Person.Type
const alice = Schema.decodeUnknownSync(Person)({ name: "Alice", age: 30 })
console.log(alice)
// { name: 'Alice', age: 30 }
Namespace for struct field type utilities.
Details
These types compute the decoded Type, encoded Encoded, and constructor
input MakeIn of a
Struct
from its field map, handling optional,
mutable, and other field modifiers automatically.
Struct.Fields — constraint for the field map object
Struct.Type<F> — decoded type of the struct
Struct.Encoded<F> — encoded type of the struct
Struct.MakeIn<F> — constructor input (optional/defaulted fields may be omitted)
Struct.DecodingServices<F> / Struct.EncodingServices<F> — required services
Type-level representation returned by
Struct
.
Struct<function (type parameter) F in serveRemote<Self, F extends PriorityItemFields = PriorityItemFields, E = never, R = never, RR = never>(tag: HyperlinkTag<Self, PriorityInstanceSpec<F>>, config: PriorityLayerConfig<Schema.Struct<F>["Type"], E, R, RR>): Layer.Layer<HandlerContextOf<PriorityInstanceSpec<F>>, never, R | RR>F>["Type"], function (type parameter) E in serveRemote<Self, F extends PriorityItemFields = PriorityItemFields, E = never, R = never, RR = never>(tag: HyperlinkTag<Self, PriorityInstanceSpec<F>>, config: PriorityLayerConfig<Schema.Struct<F>["Type"], E, R, RR>): Layer.Layer<HandlerContextOf<PriorityInstanceSpec<F>>, never, R | RR>E, function (type parameter) R in serveRemote<Self, F extends PriorityItemFields = PriorityItemFields, E = never, R = never, RR = never>(tag: HyperlinkTag<Self, PriorityInstanceSpec<F>>, config: PriorityLayerConfig<Schema.Struct<F>["Type"], E, R, RR>): Layer.Layer<HandlerContextOf<PriorityInstanceSpec<F>>, never, R | RR>R, function (type parameter) RR in serveRemote<Self, F extends PriorityItemFields = PriorityItemFields, E = never, R = never, RR = never>(tag: HyperlinkTag<Self, PriorityInstanceSpec<F>>, config: PriorityLayerConfig<Schema.Struct<F>["Type"], E, R, RR>): Layer.Layer<HandlerContextOf<PriorityInstanceSpec<F>>, never, R | RR>RR>,
): import LayerLayer.interface Layer<in ROut, out E = never, out RIn = never>A Layer describes how to build one or more services for dependency injection.
When to use
Use to model construction of application services for dependency injection,
especially when services have dependencies, can fail during construction, or
need scoped setup and release.
Details
A Layer<ROut, E, RIn> represents ROut as the services this layer
provides, E as the possible errors during layer construction, and RIn as
the services this layer requires as dependencies.
Layer<type HandlerContextOf<S extends Spec> = RpcUnionOf<S, ""> extends Rpc<infer _Tag extends string, infer _Payload extends Schema.Top, infer _Success extends Schema.Top, infer _Error extends Schema.Top, infer _Middleware extends AnyService, infer _Requires> ? Handler<_Tag> : neverThe context a server layer for a
Spec
provides: the handler for every method.
Used to pin the server layers' output type so their requirement channel stays
never — RpcGroup's own ToHandlerFn defaults that channel to any, so without
this the inferred server layer would re-leak any into anything that consumes it.
HandlerContextOf<type PriorityInstanceSpec<F extends Schema.Struct.Fields> = Omit<{
add: Hyperlink.Method<Schema.Tuple<readonly [Schema.Union<readonly [Schema.Struct<F>, Schema.$Array<Schema.Struct<F>>]>, Schema.optional<Schema.Schema<string | number>>]>, Schema.Void, Schema.Never, false, Hyperlink.MethodAnnotations & {
readonly callStyle: "pair";
} & {
description: string;
}, Hyperlink.Derive>;
enqueue: Hyperlink.Method<Schema.$Array<Schema.Struct<{
readonly item: Schema.Struct<F>;
readonly entryId: Schema.String;
readonly key: Schema.optional<Schema.String>;
... 7 more ...;
readonly attributes: Schema.optional<...>;
}>>, ... 4 more ..., Hyperlink.Derive>;
... 14 more ...;
metrics: {
...;
};
}, "add"> & {
...;
}
Full priority-queue instance contract for itemSchema F.
PriorityInstanceSpec<function (type parameter) F in serveRemote<Self, F extends PriorityItemFields = PriorityItemFields, E = never, R = never, RR = never>(tag: HyperlinkTag<Self, PriorityInstanceSpec<F>>, config: PriorityLayerConfig<Schema.Struct<F>["Type"], E, R, RR>): Layer.Layer<HandlerContextOf<PriorityInstanceSpec<F>>, never, R | RR>F>>, never, function (type parameter) R in serveRemote<Self, F extends PriorityItemFields = PriorityItemFields, E = never, R = never, RR = never>(tag: HyperlinkTag<Self, PriorityInstanceSpec<F>>, config: PriorityLayerConfig<Schema.Struct<F>["Type"], E, R, RR>): Layer.Layer<HandlerContextOf<PriorityInstanceSpec<F>>, never, R | RR>R | function (type parameter) RR in serveRemote<Self, F extends PriorityItemFields = PriorityItemFields, E = never, R = never, RR = never>(tag: HyperlinkTag<Self, PriorityInstanceSpec<F>>, config: PriorityLayerConfig<Schema.Struct<F>["Type"], E, R, RR>): Layer.Layer<HandlerContextOf<PriorityInstanceSpec<F>>, never, R | RR>RR>;
export function function serveRemote<Self, F extends QueueItemFields = QueueItemFields, R = never, RR = never, Success extends Schema.Top = Schema.Void, Error extends Schema.Top = Schema.Never>(tag: QueueTagFor<Self, F, Success, Error>, config: QueueVerbConfig<F, QueueErrorValueOf<Error>, R, RR, Success>): Layer.Layer<HandlerContextOf<QueueInstanceSpec<F>>, never, R | RR> (+1 overload)Serve this queue remotely (served-only) — run the worker / refill / persist
engine behind the tag, mount its RPC handlers, and register into
Hyperlink.servedHyperServicesLayer
,
without granting the local instance (no yield* Tag in the serving process). The engine's worker
requirement R is preserved, so a per-HyperService Layer.provide discharges it in isolation — the
queue's counterpart to
Hyperlink.serveRemote
.
Reach for this (with
Node.httpServer
) for a pure gateway/edge that exposes the queue for
remote clients but never consumes it locally; use
serve
when the serving node also drives it.
Node.httpServer([
WorkPool.serveRemote(RosterImportQueue, rosterCfg).pipe(Layer.provide(emptyHookSource)),
WorkPool.serveRemote(MediaImportQueue, mediaCfg).pipe(Layer.provide(emptyHookSource)),
]).pipe(Layer.provide(NodeHttpServer.layer(() => createServer(), { port })));
serveRemote(tag: AnyPoolTagtag: type AnyPoolTag = QueueTagFor<unknown, QueueItemFields, Schema.Top, Schema.Top> | Hyperlink.HyperlinkTag<unknown, PriorityInstanceSpec<PriorityItemFields>, {
readonly enqueue: (payload: readonly {
attempts: number;
item: Schema.Struct.ReadonlySide<PriorityItemFields, "Type">;
entryId: string;
priority: "high" | "normal" | "low";
timestamps: {
readonly enqueuedAt: DateTime.Utc;
readonly startedAt?: DateTime.Utc | undefined;
readonly completedAt?: DateTime.Utc | undefined;
readonly interruptedAt?: DateTime.Utc | undefined;
};
... 5 more ...;
lane?: number | undefined;
}[]) => Effect.Effect<...>;
... 15 more ...;
readonly add: (arg0: unknown, arg1?: unknown) => Effect.Effect<...>;
}>
A WorkPool tag — plain or
priority
— the runtime verbs dispatch over by kind.
AnyPoolTag, config: unknownconfig: unknown): import LayerLayer.Any {
return const isPriorityTag: (
tag: AnyPoolTag
) => tag is HyperlinkTag<
unknown,
PriorityInstanceSpec<PriorityItemFields>
>
True when tag was minted by
priority
— routes to the leveled engine.
isPriorityTag(tag: AnyPoolTagtag)
? const withDefaultMemory: <A, E, R>(
layer: Layer.Layer<A, E, R | Store.Storage>
) => Layer.Layer<A | Store.Storage, E, R>
Satisfy
Store.Storage
with the ephemeral default and export it for readback.
Prefer
layer
Layer.provide(AppStore.layer…).
withDefaultMemory(
import LayerLayer.const unwrap: <A, E1, R1, E, R>(
self: Effect<Layer<A, E1, R1>, E, R>
) => Layer<
A,
E | E1,
R1 | Exclude<R, Scope.Scope>
>
Unwraps a Layer from an Effect, flattening the nested structure.
When to use
Use when you have an Effect that produces a Layer and you want to
use that layer directly.
Details
The resulting Layer will have the combined error and dependency types from
both the outer Effect and the inner Layer.
Example (Unwrapping an effectful layer)
import { Context, Effect, Layer } from "effect"
class Database extends Context.Service<Database, {
readonly query: (sql: string) => Effect.Effect<string>
}>()("Database") {}
const layerEffect = Effect.succeed(
Layer.succeed(Database, { query: Effect.fn("Database.query")((sql: string) => Effect.succeed("result")) })
)
const unwrappedLayer = Layer.unwrap(layerEffect)
unwrap(
import EffectEffect.const map: {
<A, B>(f: (a: A) => B): <E, R>(
self: Effect<A, E, R>
) => Effect<B, E, R>
<A, E, R, B>(
self: Effect<A, E, R>,
f: (a: A) => B
): Effect<B, E, R>
}
Transforms the value inside an effect by applying a function to it.
When to use
Use to transform an effect's success value with a function that returns a
plain value, producing a new effect without changing the original effect's
typed error or context requirements.
Details
map takes a function and applies it to the value contained within an
effect, creating a new effect with the transformed value.
It's important to note that effects are immutable, meaning that the original
effect is not modified. Instead, a new effect is returned with the updated
value.
Example (Choosing map syntax variants)
import { Effect, pipe } from "effect"
const myEffect = Effect.succeed(1)
const transformation = (n: number) => n + 1
const mappedWithPipe = pipe(myEffect, Effect.map(transformation))
const mappedWithDataFirst = Effect.map(myEffect, transformation)
const mappedWithMethod = myEffect.pipe(Effect.map(transformation))
Example (Adding a service charge)
import { Effect, pipe } from "effect"
const addServiceCharge = (amount: number) => amount + 1
const fetchTransactionAmount = Effect.promise(() => Promise.resolve(100))
const finalAmount = pipe(
fetchTransactionAmount,
Effect.map(addServiceCharge)
)
Effect.runPromise(finalAmount).then(console.log)
// Output: 101
map(
const buildPriorityImpl: <
Self,
F extends PriorityItemFields,
E,
R,
RR = never
>(
tag: HyperlinkTag<
Self,
PriorityInstanceSpec<F>
>,
config: PriorityLayerConfig<
Schema.Struct<F>["Type"],
E,
R,
RR
>
) => Effect.Effect<
Hyperlink.Driver<
PriorityInstanceSpec<F>,
R | RR
>,
never,
R | RR | Scope.Scope | Store.Storage
>
buildPriorityImpl(
tag: Hyperlink.HyperlinkTag<unknown, PriorityInstanceSpec<PriorityItemFields>, {
readonly enqueue: (payload: readonly {
attempts: number;
item: Schema.Struct.ReadonlySide<PriorityItemFields, "Type">;
entryId: string;
priority: "high" | "normal" | "low";
timestamps: {
readonly enqueuedAt: DateTime.Utc;
readonly startedAt?: DateTime.Utc | undefined;
readonly completedAt?: DateTime.Utc | undefined;
readonly interruptedAt?: DateTime.Utc | undefined;
};
... 5 more ...;
lane?: number | undefined;
}[]) => Effect.Effect<...>;
... 15 more ...;
readonly add: (arg0: unknown, arg1?: unknown) => Effect.Effect<...>;
}>
(parameter) tag: {
key: Identifier;
Service: {
enqueue: (payload: ReadonlyArray<{ attempts: number; item: Schema.Struct.ReadonlySide<PriorityItemFields, 'Type'>; entryId: string; priority: 'high' | 'normal' | 'low'; timestamps: { readonly enqueuedAt: DateTime.Utc; readonly startedAt?: DateTime.…;
release: (payload: { options?: { readonly releaseId?: string | undefined; readonly attributes?: { readonly [x: string]: JsonValue } | undefined; readonly scope?: 'pendingOnly' | undefined } | undefined }) => Effect.Effect<ReadonlyArray<{ readonly a…;
releaseEncoded: (payload: { options?: { readonly releaseId?: string | undefined; readonly attributes?: { readonly [x: string]: JsonValue } | undefined; readonly scope?: 'pendingOnly' | undefined } | undefined }) => Effect.Effect<ReadonlyArray<{ readonly a…;
deadLetter: (payload: { selector: { readonly key?: string | undefined; readonly item?: Schema.Struct.ReadonlySide<PriorityItemFields, 'Type'> | undefined; readonly entryId?: string | undefined }; options: { readonly reason: string; readonly attributes…;
drop: (payload: { selector: { readonly key?: string | undefined; readonly item?: Schema.Struct.ReadonlySide<PriorityItemFields, 'Type'> | undefined; readonly entryId?: string | undefined }; options: { readonly reason: string; readonly attributes…;
events: Stream.Stream<Schema.Struct.ReadonlySide<{ readonly _tag: Schema.tag<'Start'>; readonly key: Schema.String }, 'Type'> | { readonly entries: ReadonlyArray<{ readonly attempts: number; readonly item: Schema.Struct.ReadonlySide<PriorityItemFi…;
status: Hyperlink.Subscribable<Schema.Struct.ReadonlySide<{ readonly sizes: Schema.$Record<Schema.String, Schema.Number>; readonly paused: Schema.Boolean; readonly inFlight: Schema.Number; readonly completed: Schema.Number; readonly phase: Schema.…;
size: Hyperlink.Subscribable<number>;
isEmpty: Hyperlink.Subscribable<boolean>;
start: Effect.Effect<void, never, never>;
pause: Effect.Effect<void, never, never>;
resume: Effect.Effect<void, never, never>;
shutdown: Effect.Effect<void, never, never>;
clear: Effect.Effect<number, never, never>;
metrics: { readonly stream: Stream.Stream<{ readonly inFlight: number; readonly completed: number; readonly avgWaitMillis: { readonly high?: number | undefined; readonly normal?: number | undefined; readonly low?: number | undefined }; readonly win…;
levelSizes: Effect.Effect<ReadonlyArray<number>, never, never>;
add: (arg0: unknown, arg1?: unknown) => Effect.Effect<void, never, never>;
};
description: string | undefined;
of: (this: void, self: { readonly enqueue: (payload: ReadonlyArray<{ attempts: number; item: Schema.Struct.ReadonlySide<PriorityItemFields, 'Type'>; entryId: string; priority: 'high' | 'normal' | 'low'; timestamps: { readonly enqueuedAt: DateT…;
context: (self: { readonly enqueue: (payload: ReadonlyArray<{ attempts: number; item: Schema.Struct.ReadonlySide<PriorityItemFields, 'Type'>; entryId: string; priority: 'high' | 'normal' | 'low'; timestamps: { readonly enqueuedAt: DateTime.Utc; rea…;
use: (f: (service: { readonly enqueue: (payload: ReadonlyArray<{ attempts: number; item: Schema.Struct.ReadonlySide<PriorityItemFields, 'Type'>; entryId: string; priority: 'high' | 'normal' | 'low'; timestamps: { readonly enqueuedAt: DateTime.U…;
useSync: (f: (service: { readonly enqueue: (payload: ReadonlyArray<{ attempts: number; item: Schema.Struct.ReadonlySide<PriorityItemFields, 'Type'>; entryId: string; priority: 'high' | 'normal' | 'low'; timestamps: { readonly enqueuedAt: DateTime.U…;
Identifier: Identifier;
stack: string | undefined;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
tag,
config: unknownconfig as type PriorityLayerConfig<
A,
E,
R,
RR = never
> = Omit<
WorkPoolPriorityConfigWithItemSchema<A, E, R>,
"itemSchema" | "refill" | "name"
> & {
readonly refill?: {
readonly onStart?: boolean
readonly onDrained?: boolean
readonly load: (
queue: WorkPoolPriorityHandle<
A,
E,
QueueEnqueueErrors,
never
>
) => Effect.Effect<void, never, RR>
}
}
Worker/layer config for a toolkit priority queue (tag carries itemSchema).
PriorityLayerConfig<import SchemaSchema.interface Struct<Fields extends Schema.Struct.Fields>Defines a struct schema from a map of field schemas.
Details
Each field value is a schema. Use
optionalKey
or
optional
to
mark fields as optional, and
mutableKey
to mark them as mutable.
The resulting schema's Type is a readonly object type with the fields'
decoded types. The Encoded form mirrors the field schemas' encoded types.
Example (Defining a basic struct)
import { Schema } from "effect"
const Person = Schema.Struct({
name: Schema.String,
age: Schema.Number,
email: Schema.optionalKey(Schema.String)
})
// { readonly name: string; readonly age: number; readonly email?: string }
type Person = typeof Person.Type
const alice = Schema.decodeUnknownSync(Person)({ name: "Alice", age: 30 })
console.log(alice)
// { name: 'Alice', age: 30 }
Namespace for struct field type utilities.
Details
These types compute the decoded Type, encoded Encoded, and constructor
input MakeIn of a
Struct
from its field map, handling optional,
mutable, and other field modifiers automatically.
Struct.Fields — constraint for the field map object
Struct.Type<F> — decoded type of the struct
Struct.Encoded<F> — encoded type of the struct
Struct.MakeIn<F> — constructor input (optional/defaulted fields may be omitted)
Struct.DecodingServices<F> / Struct.EncodingServices<F> — required services
Type-level representation returned by
Struct
.
Struct<type PriorityItemFields = {
[x: string]: Schema.Codec<
unknown,
unknown,
never,
never
>
}
PriorityItemFields>["Type"], never, never, never>,
),
(built: Hyperlink.Driver<
PriorityInstanceSpec<PriorityItemFields>,
never
>
(parameter) built: {
impl: WithRequirement<ImplOf<S>, R>;
workerContext: Context.Context<R>;
}
built) => import HyperlinkHyperlink.const serveRemoteDriver: <
S extends Spec,
R
>(
tag: {
readonly [wireKeySym]: string
readonly [specSym]: FlatSpec
readonly [specTypeSym]?: S
readonly [groupSym]: ServeRemoteTag[typeof groupSym]
},
driver: Driver<S, R>
) => Layer.Layer<HandlerContextOf<S>, never, R>
Served-only mount for a
Driver
— preserves the driver's requirement R on the Layer.
Separate from
serveRemote
so plain-impl ServeRequirements inference stays sharp and
open-S Driver overloads don't hit TS2589. Used by Gate / Daemon / WorkPool /
serve
.
Success channel is
HandlerContextOf
<S> when S is concrete on the tag; callers that
already name handler slots on their public return can treat this as the R-preserving mount.
serveRemoteDriver(tag: Hyperlink.HyperlinkTag<unknown, PriorityInstanceSpec<PriorityItemFields>, {
readonly enqueue: (payload: readonly {
attempts: number;
item: Schema.Struct.ReadonlySide<PriorityItemFields, "Type">;
entryId: string;
priority: "high" | "normal" | "low";
timestamps: {
readonly enqueuedAt: DateTime.Utc;
readonly startedAt?: DateTime.Utc | undefined;
readonly completedAt?: DateTime.Utc | undefined;
readonly interruptedAt?: DateTime.Utc | undefined;
};
... 5 more ...;
lane?: number | undefined;
}[]) => Effect.Effect<...>;
... 15 more ...;
readonly add: (arg0: unknown, arg1?: unknown) => Effect.Effect<...>;
}>
(parameter) tag: {
key: Identifier;
Service: {
enqueue: (payload: ReadonlyArray<{ attempts: number; item: Schema.Struct.ReadonlySide<PriorityItemFields, 'Type'>; entryId: string; priority: 'high' | 'normal' | 'low'; timestamps: { readonly enqueuedAt: DateTime.Utc; readonly startedAt?: DateTime.…;
release: (payload: { options?: { readonly releaseId?: string | undefined; readonly attributes?: { readonly [x: string]: JsonValue } | undefined; readonly scope?: 'pendingOnly' | undefined } | undefined }) => Effect.Effect<ReadonlyArray<{ readonly a…;
releaseEncoded: (payload: { options?: { readonly releaseId?: string | undefined; readonly attributes?: { readonly [x: string]: JsonValue } | undefined; readonly scope?: 'pendingOnly' | undefined } | undefined }) => Effect.Effect<ReadonlyArray<{ readonly a…;
deadLetter: (payload: { selector: { readonly key?: string | undefined; readonly item?: Schema.Struct.ReadonlySide<PriorityItemFields, 'Type'> | undefined; readonly entryId?: string | undefined }; options: { readonly reason: string; readonly attributes…;
drop: (payload: { selector: { readonly key?: string | undefined; readonly item?: Schema.Struct.ReadonlySide<PriorityItemFields, 'Type'> | undefined; readonly entryId?: string | undefined }; options: { readonly reason: string; readonly attributes…;
events: Stream.Stream<Schema.Struct.ReadonlySide<{ readonly _tag: Schema.tag<'Start'>; readonly key: Schema.String }, 'Type'> | { readonly entries: ReadonlyArray<{ readonly attempts: number; readonly item: Schema.Struct.ReadonlySide<PriorityItemFi…;
status: Hyperlink.Subscribable<Schema.Struct.ReadonlySide<{ readonly sizes: Schema.$Record<Schema.String, Schema.Number>; readonly paused: Schema.Boolean; readonly inFlight: Schema.Number; readonly completed: Schema.Number; readonly phase: Schema.…;
size: Hyperlink.Subscribable<number>;
isEmpty: Hyperlink.Subscribable<boolean>;
start: Effect.Effect<void, never, never>;
pause: Effect.Effect<void, never, never>;
resume: Effect.Effect<void, never, never>;
shutdown: Effect.Effect<void, never, never>;
clear: Effect.Effect<number, never, never>;
metrics: { readonly stream: Stream.Stream<{ readonly inFlight: number; readonly completed: number; readonly avgWaitMillis: { readonly high?: number | undefined; readonly normal?: number | undefined; readonly low?: number | undefined }; readonly win…;
levelSizes: Effect.Effect<ReadonlyArray<number>, never, never>;
add: (arg0: unknown, arg1?: unknown) => Effect.Effect<void, never, never>;
};
description: string | undefined;
of: (this: void, self: { readonly enqueue: (payload: ReadonlyArray<{ attempts: number; item: Schema.Struct.ReadonlySide<PriorityItemFields, 'Type'>; entryId: string; priority: 'high' | 'normal' | 'low'; timestamps: { readonly enqueuedAt: DateT…;
context: (self: { readonly enqueue: (payload: ReadonlyArray<{ attempts: number; item: Schema.Struct.ReadonlySide<PriorityItemFields, 'Type'>; entryId: string; priority: 'high' | 'normal' | 'low'; timestamps: { readonly enqueuedAt: DateTime.Utc; rea…;
use: (f: (service: { readonly enqueue: (payload: ReadonlyArray<{ attempts: number; item: Schema.Struct.ReadonlySide<PriorityItemFields, 'Type'>; entryId: string; priority: 'high' | 'normal' | 'low'; timestamps: { readonly enqueuedAt: DateTime.U…;
useSync: (f: (service: { readonly enqueue: (payload: ReadonlyArray<{ attempts: number; item: Schema.Struct.ReadonlySide<PriorityItemFields, 'Type'>; entryId: string; priority: 'high' | 'normal' | 'low'; timestamps: { readonly enqueuedAt: DateTime.U…;
Identifier: Identifier;
stack: string | undefined;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
tag, built: Hyperlink.Driver<
PriorityInstanceSpec<PriorityItemFields>,
never
>
(parameter) built: {
impl: WithRequirement<ImplOf<S>, R>;
workerContext: Context.Context<R>;
}
built),
),
),
)
: const withDefaultMemory: <A, E, R>(
layer: Layer.Layer<A, E, R | Store.Storage>
) => Layer.Layer<A | Store.Storage, E, R>
Satisfy
Store.Storage
with the ephemeral default and export it for readback.
Prefer
layer
Layer.provide(AppStore.layer…).
withDefaultMemory(
import LayerLayer.const unwrap: <A, E1, R1, E, R>(
self: Effect<Layer<A, E1, R1>, E, R>
) => Layer<
A,
E | E1,
R1 | Exclude<R, Scope.Scope>
>
Unwraps a Layer from an Effect, flattening the nested structure.
When to use
Use when you have an Effect that produces a Layer and you want to
use that layer directly.
Details
The resulting Layer will have the combined error and dependency types from
both the outer Effect and the inner Layer.
Example (Unwrapping an effectful layer)
import { Context, Effect, Layer } from "effect"
class Database extends Context.Service<Database, {
readonly query: (sql: string) => Effect.Effect<string>
}>()("Database") {}
const layerEffect = Effect.succeed(
Layer.succeed(Database, { query: Effect.fn("Database.query")((sql: string) => Effect.succeed("result")) })
)
const unwrappedLayer = Layer.unwrap(layerEffect)
unwrap(
import EffectEffect.const map: {
<A, B>(f: (a: A) => B): <E, R>(
self: Effect<A, E, R>
) => Effect<B, E, R>
<A, E, R, B>(
self: Effect<A, E, R>,
f: (a: A) => B
): Effect<B, E, R>
}
Transforms the value inside an effect by applying a function to it.
When to use
Use to transform an effect's success value with a function that returns a
plain value, producing a new effect without changing the original effect's
typed error or context requirements.
Details
map takes a function and applies it to the value contained within an
effect, creating a new effect with the transformed value.
It's important to note that effects are immutable, meaning that the original
effect is not modified. Instead, a new effect is returned with the updated
value.
Example (Choosing map syntax variants)
import { Effect, pipe } from "effect"
const myEffect = Effect.succeed(1)
const transformation = (n: number) => n + 1
const mappedWithPipe = pipe(myEffect, Effect.map(transformation))
const mappedWithDataFirst = Effect.map(myEffect, transformation)
const mappedWithMethod = myEffect.pipe(Effect.map(transformation))
Example (Adding a service charge)
import { Effect, pipe } from "effect"
const addServiceCharge = (amount: number) => amount + 1
const fetchTransactionAmount = Effect.promise(() => Promise.resolve(100))
const finalAmount = pipe(
fetchTransactionAmount,
Effect.map(addServiceCharge)
)
Effect.runPromise(finalAmount).then(console.log)
// Output: 101
map(
const buildQueueImpl: <unknown, QueueItemFields, never, never, Schema.Top, Schema.Top>(tag: QueueTagFor<unknown, QueueItemFields, Schema.Top, Schema.Top>, config: QueueVerbConfig<QueueItemFields, unknown, never, never, Schema.Top>) => Effect.Effect<Hyperlink.Driver<{
add: Hyperlink.Method<Schema.Union<readonly [Schema.Struct<QueueItemFields>, Schema.$Array<Schema.Struct<QueueItemFields>>]>, Schema.Void, Schema.Never, false, Hyperlink.MethodAnnotations & {
...;
}, {
...;
}>;
... 16 more ...;
metrics: {
...;
};
}, never>, never, Store.Storage | Scope.Scope>
Build the live
QueueEngine
handle behind tag and map it onto the toolkit service
impl — the single adapter shared by the local layer (
layer
) and the served
forms (
serve
/
serveRemote
). The worker R is captured at build time and
provided to each method, so the impl requires nothing beyond the scope; the engine queue
name defaults to the tag id (telemetry attribution) unless config.name overrides.
The queue spec has no
Hyperlink.local
members, so the resulting impl satisfies both
ImplOf (for Hyperlink.layer / Hyperlink.serve) and ServeImplOf (for Hyperlink.serveRemote).
buildQueueImpl(tag: QueueTagFor<
unknown,
QueueItemFields,
Schema.Top,
Schema.Top
>
tag, config: unknownconfig as type QueueVerbConfig<F extends QueueItemFields, E, R, RR, Success extends Schema.Top> = Omit<WorkPoolConfigWithItemSchema<Schema.Struct.View<F, "Type", Schema.Struct.TypeOptionalKeys<F>, Schema.Struct.TypeMutableKeys<F>>, E, R, QueueSuccessValueOf<Success>>, "itemSchema" | "refill"> & {
readonly refill?: {
readonly onStart?: boolean;
readonly onDrained?: boolean;
readonly load: (queue: EngineQueueHandle<Schema.Struct.View<F, "Type", Schema.Struct.TypeOptionalKeys<F>, Schema.Struct.TypeMutableKeys<F>>, E, QueueEnqueueErrors, never, QueueSuccessValueOf<...>>) => Effect.Effect<...>;
} | undefined;
}
The worker-config: param shape shared by every queue verb —
QueueLayerConfig
with the
instance item type + worker-success value recovered from F / Success.
QueueVerbConfig<type QueueItemFields = {
[x: string]: Schema.Codec<
unknown,
unknown,
never,
never
>
}
The item-schema constraint shared by
layer
/
serve
/
serveRemote
.
QueueItemFields, unknown, never, never, import SchemaSchema.Top>),
(built: Hyperlink.Driver<{
add: Hyperlink.Method<Schema.Union<readonly [Schema.Struct<QueueItemFields>, Schema.$Array<Schema.Struct<QueueItemFields>>]>, Schema.Void, Schema.Never, false, Hyperlink.MethodAnnotations & {
description: string;
}, {
(item: {
[x: string]: unknown;
}): Effect.Effect<void>;
(items: readonly {
[x: string]: unknown;
}[]): Effect.Effect<void>;
(itemOrItems: {
[x: string]: unknown;
} | readonly {
[x: string]: unknown;
}[]): Effect.Effect<void>;
}>;
prioritize: Hyperlink.Method<Schema.Union<readonly [Schema.Struct<QueueItemFields>, Schema.$Array<...>]>, ... 4 more ..., {
...;
}>;
... 15 more ...;
metrics: {
...;
};
}, never>
(parameter) built: {
impl: WithRequirement<ImplOf<S>, R>;
workerContext: Context.Context<R>;
}
built) => import HyperlinkHyperlink.const serveRemoteDriver: <
S extends Spec,
R
>(
tag: {
readonly [wireKeySym]: string
readonly [specSym]: FlatSpec
readonly [specTypeSym]?: S
readonly [groupSym]: ServeRemoteTag[typeof groupSym]
},
driver: Driver<S, R>
) => Layer.Layer<HandlerContextOf<S>, never, R>
Served-only mount for a
Driver
— preserves the driver's requirement R on the Layer.
Separate from
serveRemote
so plain-impl ServeRequirements inference stays sharp and
open-S Driver overloads don't hit TS2589. Used by Gate / Daemon / WorkPool /
serve
.
Success channel is
HandlerContextOf
<S> when S is concrete on the tag; callers that
already name handler slots on their public return can treat this as the R-preserving mount.
serveRemoteDriver(tag: QueueTagFor<
unknown,
QueueItemFields,
Schema.Top,
Schema.Top
>
tag, built: Hyperlink.Driver<{
add: Hyperlink.Method<Schema.Union<readonly [Schema.Struct<QueueItemFields>, Schema.$Array<Schema.Struct<QueueItemFields>>]>, Schema.Void, Schema.Never, false, Hyperlink.MethodAnnotations & {
description: string;
}, {
(item: {
[x: string]: unknown;
}): Effect.Effect<void>;
(items: readonly {
[x: string]: unknown;
}[]): Effect.Effect<void>;
(itemOrItems: {
[x: string]: unknown;
} | readonly {
[x: string]: unknown;
}[]): Effect.Effect<void>;
}>;
prioritize: Hyperlink.Method<Schema.Union<readonly [Schema.Struct<QueueItemFields>, Schema.$Array<...>]>, ... 4 more ..., {
...;
}>;
... 15 more ...;
metrics: {
...;
};
}, never>
(parameter) built: {
impl: WithRequirement<ImplOf<S>, R>;
workerContext: Context.Context<R>;
}
built),
),
),
);
}