<Self, S extends Spec>(tag: HyperlinkTag<Self, S>): Effect.Effect<
Record<string, PeerServiceOf<S>>,
never,
PeersId<Self>
>The resource's peer clients — the OTHER nodes' full services, keyed by node — for a resource's
own cross-node logic. Requires the peersLayer capability. Fold them with /MultiNode's
combineQuery/combineStream (or iterate) and add your own value:
totalConnections: combineQuery(peers, (p) => p.connections, combineSum).pipe(
Effect.map((others) => pool.activeCount() + others), // self + peers — you write self in
)Fold over per-instance ("leaf") fields (p.connections), not a peer's own fleet field
(p.totalConnections) — a peer client is the full service, so a fleet field is callable but would
make it re-gather its peers (a cross-node fan-out, not what you want in a fold). The plain-query
model has no type-level leaf/fleet distinction, so this is a convention, not a compile error.
export const const peers: <Self, S extends Spec>(
tag: HyperlinkTag<Self, S>
) => Effect.Effect<
Record<string, PeerServiceOf<S>>,
never,
PeersId<Self>
>
The resource's peer clients — the OTHER nodes' full services, keyed by node — for a resource's
own cross-node logic. Requires the
peersLayer
capability. Fold them with /MultiNode's
combineQuery/combineStream (or iterate) and add your own value:
totalConnections: combineQuery(peers, (p) => p.connections, combineSum).pipe(
Effect.map((others) => pool.activeCount() + others), // self + peers — you write self in
)
Fold over per-instance ("leaf") fields (p.connections), not a peer's own fleet field
(p.totalConnections) — a peer client is the full service, so a fleet field is callable but would
make it re-gather its peers (a cross-node fan-out, not what you want in a fold). The plain-query
model has no type-level leaf/fleet distinction, so this is a convention, not a compile error.
peers = <function (type parameter) Self in <Self, S extends Spec>(tag: HyperlinkTag<Self, S>): Effect.Effect<Record<string, PeerServiceOf<S>>, never, PeersId<Self>>Self, function (type parameter) S in <Self, S extends Spec>(tag: HyperlinkTag<Self, S>): Effect.Effect<Record<string, PeerServiceOf<S>>, never, PeersId<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<Record<string, PeerServiceOf<S>>, never, PeersId<Self>>Self, function (type parameter) S in <Self, S extends Spec>(tag: HyperlinkTag<Self, S>): Effect.Effect<Record<string, PeerServiceOf<S>>, never, PeersId<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<type Record<K extends keyof any, T> = {
[P in K]: T
}
Construct a type with a set of properties K of type T
Record<string, type PeerServiceOf<S extends Spec> = {
readonly [K in keyof S as S[K] extends {
readonly fleet: true
}
? never
: S[K] extends AnyLocalMethod
? never
: K]: S[K] extends {
readonly _tag: "ref"
}
? Effect.Effect<
SuccessOf<AsMethod<S[K]>>,
never,
never
>
: S[K] extends {
readonly kind: MethodKind
}
? ServiceMethod<AsMethod<S[K]>>
: S[K] extends Spec
? PeerServiceOf<S[K]>
: never
}
A peer's service as seen by
peers
— the per-instance ("leaf") wire methods only:
FleetField
s and
LocalMethod
s are excluded, so a fold can't recurse into a peer's
own fleet field. A full
ServiceOf
is assignable to it (width), so real clients fit.
PeerServiceOf<function (type parameter) S in <Self, S extends Spec>(tag: HyperlinkTag<Self, S>): Effect.Effect<Record<string, PeerServiceOf<S>>, never, PeersId<Self>>S>>, never, interface PeersId<Self>Phantom brand for the per-resource
peers
capability, so distinct resources' peer sets
don't collide in one context.
PeersId<function (type parameter) Self in <Self, S extends Spec>(tag: HyperlinkTag<Self, S>): Effect.Effect<Record<string, PeerServiceOf<S>>, never, PeersId<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 peersSym: typeof peersSymHolds a tag's per-resource
peers
capability key.
peersSym];