(path: string): <Self>(node: NodeKey<Self>) => Layer.Layer<Self>
<Self>(
node: NodeKey<Self> & {
readonly path?: string
readonly endpoints?: Endpoints
}
): Layer.Layer<Self, UnaddressedNode>Wire a node over IpcSocket — Unix-domain socket RPC (protocolIpc), connect
pinned to kind: "IpcSocket". Dual: MyNode.pipe(Hyperlink.connectIpc) uses the node's own path;
MyNode.pipe(Hyperlink.connectIpc(path)) overrides it.
export const const connectIpc: {
(path: string): <Self>(
node: NodeKey<Self>
) => Layer.Layer<Self>
<Self>(
node: NodeKey<Self> & {
readonly path?: string
readonly endpoints?: Endpoints
}
): Layer.Layer<Self, UnaddressedNode>
}
Wire a node over IpcSocket — Unix-domain socket RPC (
protocolIpc
),
connect
pinned to kind: "IpcSocket". Dual: MyNode.pipe(Hyperlink.connectIpc) uses the node's own path;
MyNode.pipe(Hyperlink.connectIpc(path)) overrides it.
connectIpc: {
(path: stringpath: string): <function (type parameter) Self in <Self>(node: NodeKey<Self>): Layer.Layer<Self>Self>(node: NodeKey<Self>(parameter) node: {
key: string;
Service: {
protocol: Context.Service.Shape<typeof RpcClient.Protocol>;
ping: Effect.Effect<number, NodeUnreachable>;
status: { readonly get: Effect.Effect<NodeStatusSnapshot, NodeUnreachable>; readonly changes: Stream.Stream<NodeStatusSnapshot, NodeUnreachable> };
logs: { readonly stream: Stream.Stream<LogEntry, NodeUnreachable>; readonly query: (options: { readonly limit: number }) => Effect.Effect<ReadonlyArray<LogEntry>, NodeUnreachable> };
};
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;
}
node: type NodeKey<HSelf> = Context.Key<HSelf, NodeProtocol>The Context key of a
Node
(HSelf = its identity): a service whose value is the
transport
NodeProtocol
. Stored on a node-bearing tag under
nodeSym
; read by
Hyperlink.client
to resolve where to connect (its requirement channel).
NodeKey<function (type parameter) Self in <Self>(node: NodeKey<Self>): Layer.Layer<Self>Self>) => 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>(node: NodeKey<Self>): Layer.Layer<Self>Self>;
<function (type parameter) Self in <Self>(node: NodeKey<Self> & {
readonly path?: string;
readonly endpoints?: Endpoints;
}): Layer.Layer<Self, UnaddressedNode>
Self>(
node: NodeKey<Self> & {
readonly path?: string
readonly endpoints?: Endpoints
}
node: type NodeKey<HSelf> = Context.Key<HSelf, NodeProtocol>The Context key of a
Node
(HSelf = its identity): a service whose value is the
transport
NodeProtocol
. Stored on a node-bearing tag under
nodeSym
; read by
Hyperlink.client
to resolve where to connect (its requirement channel).
NodeKey<function (type parameter) Self in <Self>(node: NodeKey<Self> & {
readonly path?: string;
readonly endpoints?: Endpoints;
}): Layer.Layer<Self, UnaddressedNode>
Self> & { readonly path?: string | undefinedpath?: string; readonly endpoints?: Endpoints | undefinedendpoints?: Endpoints },
): 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>(node: NodeKey<Self> & {
readonly path?: string;
readonly endpoints?: Endpoints;
}): Layer.Layer<Self, UnaddressedNode>
Self, class UnaddressedNodeclass UnaddressedNode {
message: string;
name: string;
stack: string;
cause: unknown;
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: Tag;
node: string;
}
Deriving a transport from a node that never declared one — a bare Node.Tag()("x") has no
address/kind, so connect / listen can't know how to reach it. Surfaces on the Layer / Effect
error channel (never a sync throw).
UnaddressedNode>;
} = import FnFn.const dual: <(...args: Array<any>) => any, (node: NodeKey<unknown> & {
readonly path?: string;
readonly endpoints?: Endpoints;
}, path?: string) => Layer.Layer<unknown, UnaddressedNode>>(isDataFirst: (args: IArguments) => boolean, body: (node: NodeKey<unknown> & {
readonly path?: string;
readonly endpoints?: Endpoints;
}, path?: string) => Layer.Layer<unknown, UnaddressedNode>) => ((...args: Array<any>) => any) & ((node: NodeKey<unknown> & {
readonly path?: string;
readonly endpoints?: Endpoints;
}, path?: string) => Layer.Layer<unknown, UnaddressedNode>) (+1 overload)
Creates a function that can be called in data-first style or data-last
(pipe-friendly) style.
When to use
Use to expose one implementation through both direct and pipe-friendly
call styles.
Details
Pass either the arity of the uncurried function or a predicate that decides
whether the current call is data-first. Arity is the common case. Use a
predicate when optional arguments make arity ambiguous.
Example (Selecting data-first or data-last style by arity)
import { Function, pipe } from "effect"
const sum = Function.dual<
(that: number) => (self: number) => number,
(self: number, that: number) => number
>(2, (self, that) => self + that)
console.log(sum(2, 3)) // 5
console.log(pipe(2, sum(3))) // 5
Example (Defining overloads with call signatures)
import { Function, pipe } from "effect"
const sum: {
(that: number): (self: number) => number
(self: number, that: number): number
} = Function.dual(2, (self: number, that: number): number => self + that)
console.log(sum(2, 3)) // 5
console.log(pipe(2, sum(3))) // 5
Example (Selecting data-first or data-last style with a predicate)
import { Function, pipe } from "effect"
const sum = Function.dual<
(that: number) => (self: number) => number,
(self: number, that: number) => number
>(
(args) => args.length === 2,
(self, that) => self + that
)
console.log(sum(2, 3)) // 5
console.log(pipe(2, sum(3))) // 5
dual(
(args: IArgumentsargs: IArguments) => typeof args: IArgumentsargs[0] !== "string",
(
node: NodeKey<unknown> & {
readonly path?: string
readonly endpoints?: Endpoints
}
node: type NodeKey<HSelf> = Context.Key<HSelf, NodeProtocol>The Context key of a
Node
(HSelf = its identity): a service whose value is the
transport
NodeProtocol
. Stored on a node-bearing tag under
nodeSym
; read by
Hyperlink.client
to resolve where to connect (its requirement channel).
NodeKey<unknown> & { readonly path?: string | undefinedpath?: string; readonly endpoints?: Endpoints | undefinedendpoints?: Endpoints },
path: string | undefinedpath?: string,
// Prefer the node's OWN IpcSocket endpoint over the primary `path` (multi-protocol parity).
): 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<unknown, class UnaddressedNodeclass UnaddressedNode {
message: string;
name: string;
stack: string;
cause: unknown;
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: Tag;
node: string;
}
Deriving a transport from a node that never declared one — a bare Node.Tag()("x") has no
address/kind, so connect / listen can't know how to reach it. Surfaces on the Layer / Effect
error channel (never a sync throw).
UnaddressedNode> => {
const const sock: string | undefinedsock = path: string | undefinedpath ?? node: NodeKey<unknown> & {
readonly path?: string
readonly endpoints?: Endpoints
}
node.endpoints?: Endpoints | undefinedendpoints?.Endpoints.IpcSocket?: {
readonly path: string;
} | undefined
IpcSocket?.path: string | undefinedpath ?? node: NodeKey<unknown> & {
readonly path?: string
readonly endpoints?: Endpoints
}
node.path?: string | undefinedpath;
if (const sock: string | undefinedsock === var undefinedundefined) {
return unaddressedLayer<A = never>(node: string): Layer.Layer<A, UnaddressedNode>Fail a Layer build with
UnaddressedNode
.
unaddressedLayer(node: NodeKey<unknown> & {
readonly path?: string
readonly endpoints?: Endpoints
}
node.Key<unknown, NodeProtocol>.key: stringkey);
}
return connectLayer<Self, E, RIn>(node: NodeKey<Self>, protocol: Layer.Layer<RpcClient.Protocol, E, RIn>): Layer.Layer<Self, E, RIn>Provide a node handle for node over protocol — its { protocol } plus lazy status accessors.
connectLayer(node: NodeKey<unknown> & {
readonly path?: string
readonly endpoints?: Endpoints
}
node, import HyperlinkHyperlink.const protocolIpc: (
path: string,
serialization?: Layer.Layer<RpcSerialization>
) => Layer.Layer<RpcClient.Protocol>
Build an ipc client Protocol — Effect socket RPC over a Unix-domain path
(NodeSocket.layerNet({ path })). Same-machine counterpart to
protocolHttp
/
protocolWebsocket
.
protocolIpc(const sock: stringsock));
},
);