<T extends PipeableTag>(tag: T): T & { readonly [identitySym]: true }Mark a Tag as identity-claiming (S1): layer / serve claim the resource key at Lookup first — winner runs the local impl; loser becomes a client of the winner's endpoint. Requires LookupIdentity in the layer graph (fail-closed if Lookup is down).
Pipe onto any Hyperlink / Process / Queue tag (same shape as withReadiness):
class Mail extends Hyperlink.Tag<Mail>()("app/Mail", spec).pipe(Hyperlink.identity) {}
// bind a Node on the Tag (or listen with ListenNode) — Lookup decides winner/loser:
class Mail extends Hyperlink.Tag<Mail>()("app/Mail", spec, { node: ThisNode }).pipe(
Hyperlink.identity,
) {}
Hyperlink.serve(Mail, impl).pipe(Layer.provide(Lookup.client(lookupNode)))export const const identity: <T extends PipeableTag>(
tag: T
) => T & {
readonly [identitySym]: true
}
Mark a Tag as identity-claiming (S1):
layer
/
serve
claim the resource key at
Lookup first — winner runs the local impl; loser becomes a client of the winner's endpoint.
Requires
LookupIdentity
in the layer graph (fail-closed if Lookup is down).
Pipe onto any Hyperlink / Process / Queue tag (same shape as
withReadiness
):
class Mail extends Hyperlink.Tag<Mail>()("app/Mail", spec).pipe(Hyperlink.identity) {}
// bind a Node on the Tag (or listen with ListenNode) — Lookup decides winner/loser:
class Mail extends Hyperlink.Tag<Mail>()("app/Mail", spec, { node: ThisNode }).pipe(
Hyperlink.identity,
) {}
Hyperlink.serve(Mail, impl).pipe(Layer.provide(Lookup.client(lookupNode)))
identity = <function (type parameter) T in <T extends PipeableTag>(tag: T): T & {
readonly [identitySym]: true;
}
T extends type PipeableTag = {
readonly [specSym]: FlatSpec
}
PipeableTag>(
tag: T extends PipeableTagtag: function (type parameter) T in <T extends PipeableTag>(tag: T): T & {
readonly [identitySym]: true;
}
T,
): function (type parameter) T in <T extends PipeableTag>(tag: T): T & {
readonly [identitySym]: true;
}
T & { readonly [const identitySym: typeof identitySymMarks a Tag as identity-claiming (
identity
pipe) — layer/serve claim at Lookup first.
identitySym]: true } => {
// S1: refuse identity on a Tag that already carries a multi-node fleet.
if (
(typeof tag: T extends PipeableTagtag === "object" || typeof tag: nevertag === "function") &&
tag: T extends PipeableTagtag !== null &&
"key" in tag: T extends PipeableTagtag
) {
const const fleet: readonly AnyNode[]fleet =
(tag: T & Record<"key", unknown>tag as { readonly [const nodesSym: typeof nodesSymHolds a tag's distributed set (the fleet).
nodesSym]?: interface ReadonlyArray<T>ReadonlyArray<import AnyNodeAnyNode> })[const nodesSym: typeof nodesSymHolds a tag's distributed set (the fleet).
nodesSym] ?? [];
const assertIdentityNodeCount: (
tag: {
readonly key: string
},
nodes: ReadonlyArray<AnyNode>
) => void
Throw when an identity Tag would carry more than one fleet Node.
assertIdentityNodeCount(tag: T & Record<"key", unknown>tag as { readonly key: stringkey: string }, const fleet: readonly AnyNode[]fleet);
}
return var Object: ObjectConstructorProvides functionality common to all JavaScript objects.
Object.ObjectConstructor.assign<T, {
[identitySym]: true;
}>(target: T, source: {
[identitySym]: true;
}): T & {
[identitySym]: true;
} (+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(tag: T extends PipeableTagtag, { [const identitySym: typeof identitySymMarks a Tag as identity-claiming (
identity
pipe) — layer/serve claim at Lookup first.
identitySym]: true as type const = trueconst });
};