<Self, S extends Spec>(tag: HyperlinkTag<Self, S>): Effect.Effect<
string,
never,
SelfNodeId<Self>
>The node key this instance runs as — the same key its peers are keyed by. For folds that
key per node (combineByNode), so a resource's own logic can name its own row without
hand-threading the node key. Requires the selfNodeLayer / peersLayer capability:
fleetStatus: Effect.gen(function* () {
const self = yield* Hyperlink.selfNode(FleetDatabase); // the node key I am
const peers = yield* Hyperlink.peers(FleetDatabase);
const byNode = yield* combineQuery(peers, (p) => p.status, combineByNode);
return { ...byNode, [self]: yield* ownStatus }; // key my own row, consistently
})export const const selfNode: <Self, S extends Spec>(
tag: HyperlinkTag<Self, S>
) => Effect.Effect<
string,
never,
SelfNodeId<Self>
>
The node key this instance runs as — the same key its
peers
are keyed by. For folds that
key per node (combineByNode), so a resource's own logic can name its own row without
hand-threading the node key. Requires the
selfNodeLayer
/
peersLayer
capability:
fleetStatus: Effect.gen(function* () {
const self = yield* Hyperlink.selfNode(FleetDatabase); // the node key I am
const peers = yield* Hyperlink.peers(FleetDatabase);
const byNode = yield* combineQuery(peers, (p) => p.status, combineByNode);
return { ...byNode, [self]: yield* ownStatus }; // key my own row, consistently
})
selfNode = <function (type parameter) Self in <Self, S extends Spec>(tag: HyperlinkTag<Self, S>): Effect.Effect<string, never, SelfNodeId<Self>>Self, function (type parameter) S in <Self, S extends Spec>(tag: HyperlinkTag<Self, S>): Effect.Effect<string, never, SelfNodeId<Self>>S extends Spec>(
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>(tag: HyperlinkTag<Self, S>): Effect.Effect<string, never, SelfNodeId<Self>>Self, function (type parameter) S in <Self, S extends Spec>(tag: HyperlinkTag<Self, S>): Effect.Effect<string, never, SelfNodeId<Self>>S>,
): 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<string, never, interface SelfNodeId<Self>Phantom brand for the per-resource
selfNode
capability (which node this instance runs as),
so distinct resources' self-node identities don't collide in one context.
SelfNodeId<function (type parameter) Self in <Self, S extends Spec>(tag: HyperlinkTag<Self, S>): Effect.Effect<string, never, SelfNodeId<Self>>Self>> => 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 selfNodeSym: typeof selfNodeSymHolds a tag's per-resource
selfNode
capability key.
selfNodeSym];