The Node a protocol listen (unix / http / ws) is binding (concrete or minted).
Identity claims prefer this over a Tag-bound Node when present.
export class class ListenNodeclass ListenNode {
Service: Service;
key: Identifier;
}
The Node a protocol listen (unix / http / ws) is binding (concrete or minted).
Identity claims prefer this over a Tag-bound Node when present.
ListenNode extends import ContextContext.const Service: <ListenNode, AnyNode>() => <Identifier, E, R, Args>(id: Identifier, options?: {
readonly make: ((...args: Args) => Effect<AnyNode, E, R>) | Effect<AnyNode, E, R> | undefined;
} | undefined) => Context.ServiceClass<ListenNode, Identifier, AnyNode> & ([unassigned] extends [R] ? unknown : {
readonly make: [Args] extends [never] ? Effect<AnyNode, E, R> : (...args: Args) => Effect<...>;
}) (+2 overloads)
Creates a Context service key.
When to use
Use when you need to define a context service key for a dependency that must
be provided by the surrounding context.
Details
Call Context.Service("Key") for a function-style key, or use the two-stage
form Context.Service<Self, Shape>()("Key") for class-style service
declarations. The returned key can be yielded as an Effect and passed to
Context.make, Context.add, and the Context getter functions.
Gotchas
The string key is the runtime identity of the service. Reusing the same key
string for unrelated services makes them occupy the same slot in a
Context.
Example (Creating service keys)
import { Context } from "effect"
// Create a simple service
const Database = Context.Service<{
query: (sql: string) => string
}>("Database")
// Create a service class
class Config extends Context.Service<Config, {
port: number
}>()("Config") {}
// Use the services to create contexts
const db = Context.make(Database, {
query: (sql) => `Result: ${sql}`
})
const config = Context.make(Config, { port: 8080 })
Service<class ListenNodeclass ListenNode {
Service: Service;
key: Identifier;
}
The Node a protocol listen (unix / http / ws) is binding (concrete or minted).
Identity claims prefer this over a Tag-bound Node when present.
ListenNode, type AnyNode = NodeKey<unknown> & {
readonly url: string | undefined
readonly path: string | undefined
readonly kind: ProtocolKind | undefined
readonly endpoints?: Endpoints
readonly onConflict?: OnConflict
readonly [portSym]?: number
}
A
Tag
erased — its transport endpoints set, plus the primary address
(url and/or Unix path) and
ProtocolKind
kind (the first-declared endpoint, kept for
single-protocol readers), so a tag's distributed set is self-describing about where AND how to
reach each one.
AnyNode>()(
"hyperlink-ts/internal/nodeCore/ListenNode",
) {}