<Self, S extends Spec, R = never>(
tag: HyperlinkTag<Self, S>,
impl:
| ImplOf<S>
| BuiltHyperlink<S, R>
| Effect.Effect<ImplOf<S> | BuiltHyperlink<S, R>, never, R>
): Layer.Layer<Self | Local<Self> | HandlerContextOf<S>, never, R>Expose a Tag's implementation as an RPC server layer — the served counterpart of layer. Pair it with Node.httpServer / Node.wsServer (or listen) to put it on a transport, and dial it with client / connect.
export const const serve: <
Self,
S extends Spec,
R = never
>(
tag: HyperlinkTag<Self, S>,
impl:
| ImplOf<S>
| BuiltHyperlink<S, R>
| Effect.Effect<
ImplOf<S> | BuiltHyperlink<S, R>,
never,
R
>
) => Layer.Layer<
Self | Local<Self> | HandlerContextOf<S>,
never,
R
>
Expose a
Tag
's implementation as an RPC server layer — the served counterpart of
layer
. Pair it with
Node.httpServer
/
Node.wsServer
(or
listen
) to
put it on a transport, and dial it with
client
/
connect
.
serve = <function (type parameter) Self in <Self, S extends Spec, R = never>(tag: HyperlinkTag<Self, S>, impl: ImplOf<S> | BuiltHyperlink<S, R> | Effect.Effect<ImplOf<S> | BuiltHyperlink<S, R>, never, R>): Layer.Layer<Self | Local<Self> | HandlerContextOf<S>, never, R>Self, function (type parameter) S in <Self, S extends Spec, R = never>(tag: HyperlinkTag<Self, S>, impl: ImplOf<S> | BuiltHyperlink<S, R> | Effect.Effect<ImplOf<S> | BuiltHyperlink<S, R>, never, R>): Layer.Layer<Self | Local<Self> | HandlerContextOf<S>, never, R>S extends Spec, function (type parameter) R in <Self, S extends Spec, R = never>(tag: HyperlinkTag<Self, S>, impl: ImplOf<S> | BuiltHyperlink<S, R> | Effect.Effect<ImplOf<S> | BuiltHyperlink<S, R>, never, R>): Layer.Layer<Self | Local<Self> | HandlerContextOf<S>, never, R>R = never>(
tag: HyperlinkTag<Self, S>(parameter) tag: {
groupId: string;
description: string | undefined;
key: Identifier;
of: (this: void, self: Simplify<{ readonly [K in keyof S]: S[K] extends FromLocalMethod<infer M> ? InjectLocal<M, Self> : S[K] extends LocalMethod<infer T> ? LocalEffect<T, never, Self> : S[K] extends { readonly _tag: 'constant'; } ? SuccessOf…;
context: (self: Simplify<{ readonly [K in keyof S]: S[K] extends FromLocalMethod<infer M> ? InjectLocal<M, Self> : S[K] extends LocalMethod<infer T> ? LocalEffect<T, never, Self> : S[K] extends { readonly _tag: 'constant'; } ? SuccessOf<AsMethod<S[…;
use: (f: (service: Simplify<{ readonly [K in keyof S]: S[K] extends FromLocalMethod<infer M> ? InjectLocal<M, Self> : S[K] extends LocalMethod<infer T> ? LocalEffect<T, never, Self> : S[K] extends { readonly _tag: 'constant'; } ? SuccessOf<AsMe…;
useSync: (f: (service: Simplify<{ readonly [K in keyof S]: S[K] extends FromLocalMethod<infer M> ? InjectLocal<M, Self> : S[K] extends LocalMethod<infer T> ? LocalEffect<T, never, Self> : S[K] extends { readonly _tag: 'constant'; } ? SuccessOf<AsMe…;
Identifier: Identifier;
Service: Shape;
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 { ...; } ? SuccessOf<...> : S[K] extends { ...; } ? Subscribable<...> : S[K] extends { ...; } ? ClientMethod<...> : S[K] extends Spec ? Simplify<...> : never; }>>The type of a resource tag carrying spec S — what
Hyperlink.Tag
/ a
Hyperlink.tagFor
factory produce (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 <Self, S extends Spec, R = never>(tag: HyperlinkTag<Self, S>, impl: ImplOf<S> | BuiltHyperlink<S, R> | Effect.Effect<ImplOf<S> | BuiltHyperlink<S, R>, never, R>): Layer.Layer<Self | Local<Self> | HandlerContextOf<S>, never, R>Self, function (type parameter) S in <Self, S extends Spec, R = never>(tag: HyperlinkTag<Self, S>, impl: ImplOf<S> | BuiltHyperlink<S, R> | Effect.Effect<ImplOf<S> | BuiltHyperlink<S, R>, never, R>): Layer.Layer<Self | Local<Self> | HandlerContextOf<S>, never, R>S>,
impl: | ImplOf<S>
| BuiltHyperlink<S, R>
| Effect.Effect<
ImplOf<S> | BuiltHyperlink<S, R>,
never,
R
>
impl:
| type ImplOf<S extends Spec> = {
readonly [K in keyof S]: S[K] extends FromLocalMethod<
infer M
>
? M
: S[K] extends LocalMethod<infer T>
? T
: S[K] extends {
readonly _tag: "ref"
}
? Subscribable<SuccessOf<AsMethod<S[K]>>>
: S[K] extends {
readonly kind: MethodKind
}
? ServiceMethod<AsMethod<S[K]>>
: S[K] extends Spec
? ImplOf<S[K]>
: never
}
The implementation a
localLayer
/
serve
expects: wire members are their
Effect/Stream/function, and each
LocalMethod
is its raw value T (the toolkit wraps
it to require the
Local
). When an impl needs a capability (e.g.
peers
) to
build, provide it via the Effect form of
Hyperlink.layer
/
Hyperlink.serve
— resolve it once, and the members close over it.
A value field's impl is the Stream that feeds it (typically a SubscriptionRef's .changes),
and a constant's is the Effect<A> resolved once — both differ from how they surface in
ServiceOf
(a plain A), so annotate an impl with ImplOf, not ServiceOf.
ImplOf<function (type parameter) S in <Self, S extends Spec, R = never>(tag: HyperlinkTag<Self, S>, impl: ImplOf<S> | BuiltHyperlink<S, R> | Effect.Effect<ImplOf<S> | BuiltHyperlink<S, R>, never, R>): Layer.Layer<Self | Local<Self> | HandlerContextOf<S>, never, R>S>
| interface BuiltHyperlink<S extends Spec, R>A resource impl before worker-context discharge — the impl still carries requirement R on its
Effect methods, paired with the
Context.Context
captured at build time. Used by
QueueHyperlink
,
RunHyperlink
, and
Process
(any toolkit resource that builds
its driver under ambient R).
layer
/
serve
grant locally via
grantLocal
;
serveRemote
defers discharge to each wire call via
invokeWireMethodWithContext
so
one materialization backs both paths.
BuiltHyperlink<function (type parameter) S in <Self, S extends Spec, R = never>(tag: HyperlinkTag<Self, S>, impl: ImplOf<S> | BuiltHyperlink<S, R> | Effect.Effect<ImplOf<S> | BuiltHyperlink<S, R>, never, R>): Layer.Layer<Self | Local<Self> | HandlerContextOf<S>, never, R>S, function (type parameter) R in <Self, S extends Spec, R = never>(tag: HyperlinkTag<Self, S>, impl: ImplOf<S> | BuiltHyperlink<S, R> | Effect.Effect<ImplOf<S> | BuiltHyperlink<S, R>, never, R>): Layer.Layer<Self | Local<Self> | HandlerContextOf<S>, never, R>R>
| import EffectEffect.interface Effect<out A, out E = never, out R = never>The Effect interface defines a value that lazily describes a workflow or
job. The workflow requires some context R, and may fail with an error of
type E, or succeed with a value of type A.
When to use
Use when you need to represent a lazy, composable workflow that can require
services, fail with a typed error, or succeed with a typed value.
Details
Effect values model resourceful interaction with the outside world,
including synchronous, asynchronous, concurrent, and parallel interaction.
They use a fiber-based concurrency model, with built-in support for
scheduling, fine-grained interruption, structured concurrency, and high
scalability.
To run an Effect value, you need a Runtime, which is a type that is
capable of executing Effect values.
Effect<type ImplOf<S extends Spec> = {
readonly [K in keyof S]: S[K] extends FromLocalMethod<
infer M
>
? M
: S[K] extends LocalMethod<infer T>
? T
: S[K] extends {
readonly _tag: "ref"
}
? Subscribable<SuccessOf<AsMethod<S[K]>>>
: S[K] extends {
readonly kind: MethodKind
}
? ServiceMethod<AsMethod<S[K]>>
: S[K] extends Spec
? ImplOf<S[K]>
: never
}
The implementation a
localLayer
/
serve
expects: wire members are their
Effect/Stream/function, and each
LocalMethod
is its raw value T (the toolkit wraps
it to require the
Local
). When an impl needs a capability (e.g.
peers
) to
build, provide it via the Effect form of
Hyperlink.layer
/
Hyperlink.serve
— resolve it once, and the members close over it.
A value field's impl is the Stream that feeds it (typically a SubscriptionRef's .changes),
and a constant's is the Effect<A> resolved once — both differ from how they surface in
ServiceOf
(a plain A), so annotate an impl with ImplOf, not ServiceOf.
ImplOf<function (type parameter) S in <Self, S extends Spec, R = never>(tag: HyperlinkTag<Self, S>, impl: ImplOf<S> | BuiltHyperlink<S, R> | Effect.Effect<ImplOf<S> | BuiltHyperlink<S, R>, never, R>): Layer.Layer<Self | Local<Self> | HandlerContextOf<S>, never, R>S> | interface BuiltHyperlink<S extends Spec, R>A resource impl before worker-context discharge — the impl still carries requirement R on its
Effect methods, paired with the
Context.Context
captured at build time. Used by
QueueHyperlink
,
RunHyperlink
, and
Process
(any toolkit resource that builds
its driver under ambient R).
layer
/
serve
grant locally via
grantLocal
;
serveRemote
defers discharge to each wire call via
invokeWireMethodWithContext
so
one materialization backs both paths.
BuiltHyperlink<function (type parameter) S in <Self, S extends Spec, R = never>(tag: HyperlinkTag<Self, S>, impl: ImplOf<S> | BuiltHyperlink<S, R> | Effect.Effect<ImplOf<S> | BuiltHyperlink<S, R>, never, R>): Layer.Layer<Self | Local<Self> | HandlerContextOf<S>, never, R>S, function (type parameter) R in <Self, S extends Spec, R = never>(tag: HyperlinkTag<Self, S>, impl: ImplOf<S> | BuiltHyperlink<S, R> | Effect.Effect<ImplOf<S> | BuiltHyperlink<S, R>, never, R>): Layer.Layer<Self | Local<Self> | HandlerContextOf<S>, never, R>R>, never, function (type parameter) R in <Self, S extends Spec, R = never>(tag: HyperlinkTag<Self, S>, impl: ImplOf<S> | BuiltHyperlink<S, R> | Effect.Effect<ImplOf<S> | BuiltHyperlink<S, R>, never, R>): Layer.Layer<Self | Local<Self> | HandlerContextOf<S>, never, R>R>,
): 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<function (type parameter) Self in <Self, S extends Spec, R = never>(tag: HyperlinkTag<Self, S>, impl: ImplOf<S> | BuiltHyperlink<S, R> | Effect.Effect<ImplOf<S> | BuiltHyperlink<S, R>, never, R>): Layer.Layer<Self | Local<Self> | HandlerContextOf<S>, never, R>Self | interface Local<in out Self>Granted only by a resource's local layer (
Hyperlink.layer
/
serve
) — never by
Hyperlink.client
. Local to this runtime's materialized impl for the tag (not a remote
client, not a peer). A
LocalMethod
carries it in its requirement channel, so calling a
non-serializable method against a client is a compile error (unsatisfied requirement); the
same call resolves when the local layer is provided. Branded by Self so one resource's local
layer can't unlock another's.
Local<function (type parameter) Self in <Self, S extends Spec, R = never>(tag: HyperlinkTag<Self, S>, impl: ImplOf<S> | BuiltHyperlink<S, R> | Effect.Effect<ImplOf<S> | BuiltHyperlink<S, R>, never, R>): Layer.Layer<Self | Local<Self> | HandlerContextOf<S>, never, R>Self> | type HandlerContextOf<S extends Spec> =
RpcUnionOf<S, ""> extends Rpc.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
>
? Rpc.Handler<_Tag>
: never
The 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<function (type parameter) S in <Self, S extends Spec, R = never>(tag: HyperlinkTag<Self, S>, impl: ImplOf<S> | BuiltHyperlink<S, R> | Effect.Effect<ImplOf<S> | BuiltHyperlink<S, R>, never, R>): Layer.Layer<Self | Local<Self> | HandlerContextOf<S>, never, R>S>, never, function (type parameter) R in <Self, S extends Spec, R = never>(tag: HyperlinkTag<Self, S>, impl: ImplOf<S> | BuiltHyperlink<S, R> | Effect.Effect<ImplOf<S> | BuiltHyperlink<S, R>, never, R>): Layer.Layer<Self | Local<Self> | HandlerContextOf<S>, never, R>R> => {
// Stamp the served tag's key so an anonymous `listen` can derive a legible node name from the first
// resource it serves (see {@link servedKeyOf} / anonymousNodeKey). Stamped on the FINAL layer both
// paths return (servePlain re-merges, which would drop an earlier stamp).
const const plain: Layer.Layer<
| Self
| Local<Self>
| Rpc.ToHandler<RpcUnionOf<S, "">>,
never,
R
> & {
[servedKeySym]: string
}
plain = var Object: ObjectConstructorProvides functionality common to all JavaScript objects.
Object.ObjectConstructor.assign<Layer.Layer<Self | Local<Self> | Rpc.ToHandler<RpcUnionOf<S, "">>, never, R>, {
[servedKeySym]: string;
}>(target: Layer.Layer<Self | Local<Self> | Rpc.ToHandler<RpcUnionOf<S, "">>, never, R>, source: {
[servedKeySym]: string;
}): Layer.Layer<Self | Local<Self> | Rpc.ToHandler<RpcUnionOf<S, "">>, never, R> & {
[servedKeySym]: string;
} (+3 overloads)
Copy the values of all of the enumerable own properties from one or more source objects to a
target object. Returns the target object.
assign(const servePlain: <
Self,
S extends Spec,
R = never
>(
tag: HyperlinkTag<Self, S>,
impl:
| ImplOf<S>
| BuiltHyperlink<S, R>
| Effect.Effect<
ImplOf<S> | BuiltHyperlink<S, R>,
never,
R
>
) => Layer.Layer<
Self | Local<Self> | HandlerContextOf<S>,
never,
R
>
Serve a resource and grant its local instance from one materialization — the co-located "expose
it over RPC AND consume it in-process" case (a node that serves its resources and also yield*s them,
e.g. to read a
Hyperlink.local
member). The impl runs once, so its cells / pollers / resolved
peers
are shared: the served view and the in-process view are the same instance — no double
materialization, no second peersLayer. Register onto a node with
httpServer
like any
serve
layer; a served-only gateway (never consumed locally) uses
serve
directly.
Use the Effect form when the impl needs a capability to build (resolve peers / a pool once; the
members close over it) — R is discharged here, shared by both the grant and the handlers.
When tag is
identity
-stamped, claims at Lookup first (see
layer
): winner serves
locally; loser becomes a client of the winner (no handlers). Pass dialable options.self when the
tag has no bound
Node
.
servePlain(tag: HyperlinkTag<Self, S>(parameter) tag: {
groupId: string;
description: string | undefined;
key: Identifier;
of: (this: void, self: Simplify<{ readonly [K in keyof S]: S[K] extends FromLocalMethod<infer M> ? InjectLocal<M, Self> : S[K] extends LocalMethod<infer T> ? LocalEffect<T, never, Self> : S[K] extends { readonly _tag: 'constant'; } ? SuccessOf…;
context: (self: Simplify<{ readonly [K in keyof S]: S[K] extends FromLocalMethod<infer M> ? InjectLocal<M, Self> : S[K] extends LocalMethod<infer T> ? LocalEffect<T, never, Self> : S[K] extends { readonly _tag: 'constant'; } ? SuccessOf<AsMethod<S[…;
use: (f: (service: Simplify<{ readonly [K in keyof S]: S[K] extends FromLocalMethod<infer M> ? InjectLocal<M, Self> : S[K] extends LocalMethod<infer T> ? LocalEffect<T, never, Self> : S[K] extends { readonly _tag: 'constant'; } ? SuccessOf<AsMe…;
useSync: (f: (service: Simplify<{ readonly [K in keyof S]: S[K] extends FromLocalMethod<infer M> ? InjectLocal<M, Self> : S[K] extends LocalMethod<infer T> ? LocalEffect<T, never, Self> : S[K] extends { readonly _tag: 'constant'; } ? SuccessOf<AsMe…;
Identifier: Identifier;
Service: Shape;
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, impl: | ImplOf<S>
| BuiltHyperlink<S, R>
| Effect.Effect<
ImplOf<S> | BuiltHyperlink<S, R>,
never,
R
>
impl), {
[const servedKeySym: typeof servedKeySymStamped on a
serve
layer with the served tag's key — lets an anonymous listen derive a
legible node name from the first resource it serves without building the layer.
servedKeySym]: tag: HyperlinkTag<Self, S>(parameter) tag: {
groupId: string;
description: string | undefined;
key: Identifier;
of: (this: void, self: Simplify<{ readonly [K in keyof S]: S[K] extends FromLocalMethod<infer M> ? InjectLocal<M, Self> : S[K] extends LocalMethod<infer T> ? LocalEffect<T, never, Self> : S[K] extends { readonly _tag: 'constant'; } ? SuccessOf…;
context: (self: Simplify<{ readonly [K in keyof S]: S[K] extends FromLocalMethod<infer M> ? InjectLocal<M, Self> : S[K] extends LocalMethod<infer T> ? LocalEffect<T, never, Self> : S[K] extends { readonly _tag: 'constant'; } ? SuccessOf<AsMethod<S[…;
use: (f: (service: Simplify<{ readonly [K in keyof S]: S[K] extends FromLocalMethod<infer M> ? InjectLocal<M, Self> : S[K] extends LocalMethod<infer T> ? LocalEffect<T, never, Self> : S[K] extends { readonly _tag: 'constant'; } ? SuccessOf<AsMe…;
useSync: (f: (service: Simplify<{ readonly [K in keyof S]: S[K] extends FromLocalMethod<infer M> ? InjectLocal<M, Self> : S[K] extends LocalMethod<infer T> ? LocalEffect<T, never, Self> : S[K] extends { readonly _tag: 'constant'; } ? SuccessOf<AsMe…;
Identifier: Identifier;
Service: Shape;
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.HyperlinkTag<Self, S, Simplify<{ readonly [K in keyof S]: S[K] extends FromLocalMethod<infer M> ? InjectLocal<M, Self> : S[K] extends LocalMethod<...> ? LocalEffect<...> : S[K] extends { ...; } ? SuccessOf<...> : S[K] extends { ...; } ? Subscribable<...> : S[K] extends { ...; } ? ClientMethod<...> : S[K] extends Spec ? Simplify<...> : never; }>>.groupId: stringWire prefix — namespaces this resource's procedures on a shared RpcServer.
groupId,
});
if (!const isIdentity: (
tag: unknown
) => boolean
True when tag was piped through
identity
.
isIdentity(tag: HyperlinkTag<Self, S>(parameter) tag: {
groupId: string;
description: string | undefined;
key: Identifier;
of: (this: void, self: Simplify<{ readonly [K in keyof S]: S[K] extends FromLocalMethod<infer M> ? InjectLocal<M, Self> : S[K] extends LocalMethod<infer T> ? LocalEffect<T, never, Self> : S[K] extends { readonly _tag: 'constant'; } ? SuccessOf…;
context: (self: Simplify<{ readonly [K in keyof S]: S[K] extends FromLocalMethod<infer M> ? InjectLocal<M, Self> : S[K] extends LocalMethod<infer T> ? LocalEffect<T, never, Self> : S[K] extends { readonly _tag: 'constant'; } ? SuccessOf<AsMethod<S[…;
use: (f: (service: Simplify<{ readonly [K in keyof S]: S[K] extends FromLocalMethod<infer M> ? InjectLocal<M, Self> : S[K] extends LocalMethod<infer T> ? LocalEffect<T, never, Self> : S[K] extends { readonly _tag: 'constant'; } ? SuccessOf<AsMe…;
useSync: (f: (service: Simplify<{ readonly [K in keyof S]: S[K] extends FromLocalMethod<infer M> ? InjectLocal<M, Self> : S[K] extends LocalMethod<infer T> ? LocalEffect<T, never, Self> : S[K] extends { readonly _tag: 'constant'; } ? SuccessOf<AsMe…;
Identifier: Identifier;
Service: Shape;
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)) {
return const plain: Layer.Layer<
| Self
| Local<Self>
| Rpc.ToHandler<RpcUnionOf<S, "">>,
never,
R
> & {
[servedKeySym]: string
}
plain;
}
// Identity path requires Lookup.Identity at runtime (fail-closed). Kept off the public
// `R` channel so plain `serve` stays TS2589-free (HyperlinkTag & identity brand blows up).
const const claimed: Layer.Layer<
| Self
| Local<Self>
| Rpc.ToHandler<RpcUnionOf<S, "">>,
never,
R
>
const claimed: {
build: (memoMap: Layer.MemoMap, scope: Scope.Scope) => Effect.Effect<Context.Context<Self | Local<Self> | Rpc.ToHandler<RpcUnionOf<S, ''>>>, never, R>;
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; <…;
}
claimed = const identityClaimLayer: <
Self,
S extends Spec,
A,
E,
R
>(
tag: HyperlinkTag<Self, S>,
onWon: Layer.Layer<A, E, R>
) => Layer.Layer<
A | Self,
E | IdentitySelfRequired,
R | LookupIdentity
>
Claim tag.key at Lookup — won → onWon layer; lost → client of original.
Endpoint from
ListenNode
(protocol listen) or the Tag's bound Node — no { self } bag.
Fail-closed: requires
LookupIdentity
; missing/unaddressed →
IdentitySelfRequired
.
identityClaimLayer(tag: HyperlinkTag<Self, S>(parameter) tag: {
groupId: string;
description: string | undefined;
key: Identifier;
of: (this: void, self: Simplify<{ readonly [K in keyof S]: S[K] extends FromLocalMethod<infer M> ? InjectLocal<M, Self> : S[K] extends LocalMethod<infer T> ? LocalEffect<T, never, Self> : S[K] extends { readonly _tag: 'constant'; } ? SuccessOf…;
context: (self: Simplify<{ readonly [K in keyof S]: S[K] extends FromLocalMethod<infer M> ? InjectLocal<M, Self> : S[K] extends LocalMethod<infer T> ? LocalEffect<T, never, Self> : S[K] extends { readonly _tag: 'constant'; } ? SuccessOf<AsMethod<S[…;
use: (f: (service: Simplify<{ readonly [K in keyof S]: S[K] extends FromLocalMethod<infer M> ? InjectLocal<M, Self> : S[K] extends LocalMethod<infer T> ? LocalEffect<T, never, Self> : S[K] extends { readonly _tag: 'constant'; } ? SuccessOf<AsMe…;
useSync: (f: (service: Simplify<{ readonly [K in keyof S]: S[K] extends FromLocalMethod<infer M> ? InjectLocal<M, Self> : S[K] extends LocalMethod<infer T> ? LocalEffect<T, never, Self> : S[K] extends { readonly _tag: 'constant'; } ? SuccessOf<AsMe…;
Identifier: Identifier;
Service: Shape;
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, const plain: Layer.Layer<
| Self
| Local<Self>
| Rpc.ToHandler<RpcUnionOf<S, "">>,
never,
R
> & {
[servedKeySym]: string
}
plain) as 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<
function (type parameter) Self in <Self, S extends Spec, R = never>(tag: HyperlinkTag<Self, S>, impl: ImplOf<S> | BuiltHyperlink<S, R> | Effect.Effect<ImplOf<S> | BuiltHyperlink<S, R>, never, R>): Layer.Layer<Self | Local<Self> | HandlerContextOf<S>, never, R>Self | interface Local<in out Self>Granted only by a resource's local layer (
Hyperlink.layer
/
serve
) — never by
Hyperlink.client
. Local to this runtime's materialized impl for the tag (not a remote
client, not a peer). A
LocalMethod
carries it in its requirement channel, so calling a
non-serializable method against a client is a compile error (unsatisfied requirement); the
same call resolves when the local layer is provided. Branded by Self so one resource's local
layer can't unlock another's.
Local<function (type parameter) Self in <Self, S extends Spec, R = never>(tag: HyperlinkTag<Self, S>, impl: ImplOf<S> | BuiltHyperlink<S, R> | Effect.Effect<ImplOf<S> | BuiltHyperlink<S, R>, never, R>): Layer.Layer<Self | Local<Self> | HandlerContextOf<S>, never, R>Self> | type HandlerContextOf<S extends Spec> =
RpcUnionOf<S, ""> extends Rpc.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
>
? Rpc.Handler<_Tag>
: never
The 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<function (type parameter) S in <Self, S extends Spec, R = never>(tag: HyperlinkTag<Self, S>, impl: ImplOf<S> | BuiltHyperlink<S, R> | Effect.Effect<ImplOf<S> | BuiltHyperlink<S, R>, never, R>): Layer.Layer<Self | Local<Self> | HandlerContextOf<S>, never, R>S>,
never,
function (type parameter) R in <Self, S extends Spec, R = never>(tag: HyperlinkTag<Self, S>, impl: ImplOf<S> | BuiltHyperlink<S, R> | Effect.Effect<ImplOf<S> | BuiltHyperlink<S, R>, never, R>): Layer.Layer<Self | Local<Self> | HandlerContextOf<S>, never, R>R
>;
return var Object: ObjectConstructorProvides functionality common to all JavaScript objects.
Object.ObjectConstructor.assign<Layer.Layer<Self | Local<Self> | Rpc.ToHandler<RpcUnionOf<S, "">>, never, R>, {
[servedKeySym]: string;
}>(target: Layer.Layer<Self | Local<Self> | Rpc.ToHandler<RpcUnionOf<S, "">>, never, R>, source: {
[servedKeySym]: string;
}): Layer.Layer<Self | Local<Self> | Rpc.ToHandler<RpcUnionOf<S, "">>, never, R> & {
[servedKeySym]: string;
} (+3 overloads)
Copy the values of all of the enumerable own properties from one or more source objects to a
target object. Returns the target object.
assign(const claimed: Layer.Layer<
| Self
| Local<Self>
| Rpc.ToHandler<RpcUnionOf<S, "">>,
never,
R
>
const claimed: {
build: (memoMap: Layer.MemoMap, scope: Scope.Scope) => Effect.Effect<Context.Context<Self | Local<Self> | Rpc.ToHandler<RpcUnionOf<S, ''>>>, never, R>;
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; <…;
}
claimed, { [const servedKeySym: typeof servedKeySymStamped on a
serve
layer with the served tag's key — lets an anonymous listen derive a
legible node name from the first resource it serves without building the layer.
servedKeySym]: tag: HyperlinkTag<Self, S>(parameter) tag: {
groupId: string;
description: string | undefined;
key: Identifier;
of: (this: void, self: Simplify<{ readonly [K in keyof S]: S[K] extends FromLocalMethod<infer M> ? InjectLocal<M, Self> : S[K] extends LocalMethod<infer T> ? LocalEffect<T, never, Self> : S[K] extends { readonly _tag: 'constant'; } ? SuccessOf…;
context: (self: Simplify<{ readonly [K in keyof S]: S[K] extends FromLocalMethod<infer M> ? InjectLocal<M, Self> : S[K] extends LocalMethod<infer T> ? LocalEffect<T, never, Self> : S[K] extends { readonly _tag: 'constant'; } ? SuccessOf<AsMethod<S[…;
use: (f: (service: Simplify<{ readonly [K in keyof S]: S[K] extends FromLocalMethod<infer M> ? InjectLocal<M, Self> : S[K] extends LocalMethod<infer T> ? LocalEffect<T, never, Self> : S[K] extends { readonly _tag: 'constant'; } ? SuccessOf<AsMe…;
useSync: (f: (service: Simplify<{ readonly [K in keyof S]: S[K] extends FromLocalMethod<infer M> ? InjectLocal<M, Self> : S[K] extends LocalMethod<infer T> ? LocalEffect<T, never, Self> : S[K] extends { readonly _tag: 'constant'; } ? SuccessOf<AsMe…;
Identifier: Identifier;
Service: Shape;
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.HyperlinkTag<Self, S, Simplify<{ readonly [K in keyof S]: S[K] extends FromLocalMethod<infer M> ? InjectLocal<M, Self> : S[K] extends LocalMethod<...> ? LocalEffect<...> : S[K] extends { ...; } ? SuccessOf<...> : S[K] extends { ...; } ? Subscribable<...> : S[K] extends { ...; } ? ClientMethod<...> : S[K] extends Spec ? Simplify<...> : never; }>>.groupId: stringWire prefix — namespaces this resource's procedures on a shared RpcServer.
groupId });
};