DaemonServiceDefinition<Self, Id, E, R>Canonical daemon service declaration.
export interface interface DaemonServiceDefinition<Self, Id extends string, E, R>Canonical daemon service declaration.
DaemonServiceDefinition<function (type parameter) Self in DaemonServiceDefinition<Self, Id extends string, E, R>Self, function (type parameter) Id in DaemonServiceDefinition<Self, Id extends string, E, R>Id extends string, function (type parameter) E in DaemonServiceDefinition<Self, Id extends string, E, R>E, function (type parameter) R in DaemonServiceDefinition<Self, Id extends string, E, R>R>
extends import ContextContext.interface ServiceClass<in out Self, in out Identifier extends string, in out Shape>Class-style service key produced by Context.Service<Self, Shape>()("Id").
When to use
Use when declaring a service as a class so the class value can serve as the
Context key.
Details
The class itself is the Context key, and its string key identifies the
service at runtime.
Namespace containing helper types for class-style Context.Service
declarations.
ServiceClass<function (type parameter) Self in DaemonServiceDefinition<Self, Id extends string, E, R>Self, function (type parameter) Id in DaemonServiceDefinition<Self, Id extends string, E, R>Id, interface Daemon<out R>Managed daemon handle for Hyperlink supervision.
Daemon<function (type parameter) R in DaemonServiceDefinition<Self, Id extends string, E, R>R>>,
interface DaemonDefinition<out Id extends string, out R>Canonical daemon declaration that can be registered with a typed Hyperlink group.
DaemonDefinition<function (type parameter) Id in DaemonServiceDefinition<Self, Id extends string, E, R>Id, function (type parameter) R in DaemonServiceDefinition<Self, Id extends string, E, R>R> {
readonly DaemonServiceDefinition<Self, Id extends string, E, R>.tag: Context.Key<Self, Daemon<R>>(property) DaemonServiceDefinition<Self, Id extends string, E, R>.tag: {
key: string;
Service: {
name: string;
effect: Effect.Effect<void, never, R>;
run: () => Effect.Effect<unknown, never, R>;
snapshot: Effect.Effect<DaemonSnapshot>;
events: Stream.Stream<DaemonLiveEvent>;
polling: { readonly wake: Effect.Effect<void>; readonly resetCadence: Effect.Effect<void> };
};
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;
}
tag: import ContextContext.interface Key<out Identifier, out Shape>Typed identifier for a service stored in a Context.
When to use
Use as the typed handle for storing, retrieving, and requiring a specific
service in a Context.
Details
Identifier tracks the requirement in Effect types, while Shape is the
service implementation retrieved by the key. A key is also an Effect value,
so yielding it inside Effect.gen retrieves the service from the current
fiber context.
Key<function (type parameter) Self in DaemonServiceDefinition<Self, Id extends string, E, R>Self, interface Daemon<out R>Managed daemon handle for Hyperlink supervision.
Daemon<function (type parameter) R in DaemonServiceDefinition<Self, Id extends string, E, R>R>>;
readonly DaemonServiceDefinition<Self, Id extends string, E, R>.layer: Layer.Layer<Self>(property) DaemonServiceDefinition<Self, Id extends string, E, R>.layer: {
build: (memoMap: MemoMap, scope: Scope.Scope) => Effect<Context.Context<Self>, never, never>;
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; <…;
}
layer: 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 DaemonServiceDefinition<Self, Id extends string, E, R>Self>;
/**
* Factory defaults before {@link configure} layers (see `HyperlinkConfigure` module).
*/
readonly DaemonServiceDefinition<Self, Id extends string, E, R>.defaultSpec: DaemonMakeOptions<E, R>(property) DaemonServiceDefinition<Self, Id extends string, E, R>.defaultSpec: {
effect: Effect.Effect<void, E, RUser>;
_store: DaemonStoreWriter;
_storeScopeTag: StoreScopeTag;
_resultRef: SubscriptionRef.SubscriptionRef<Option.Option<unknown>>;
polling: AnyPollingLayer;
schedule: DaemonScheduleInitializer<RUser> | AnyScheduleLayer;
scheduleLayer: AnyScheduleLayer;
}
Factory defaults before
configure
layers (see HyperlinkConfigure module).
defaultSpec: interface DaemonMakeOptions<E, RUser>Configuration for
Daemon.make
when using the config-object form (id is separate).
DaemonMakeOptions<function (type parameter) E in DaemonServiceDefinition<Self, Id extends string, E, R>E, function (type parameter) R in DaemonServiceDefinition<Self, Id extends string, E, R>R>;
/**
* Append a configure patch; merge with {@link layer} via `Layer.provideMerge`.
*/
readonly DaemonServiceDefinition<Self, Id extends string, E, R>.configure: (patch: ConfigPatch<DaemonMakeOptions<E, R>>) => Layer.Layer<never>Append a configure patch; merge with
layer
via Layer.provideMerge.
configure: (
patch: ConfigPatch<DaemonMakeOptions<E, R>>patch: type ConfigPatch<T> = PartialConfigPatch<T> | ((previous: T) => T)Patch for a hyperlink or daemon spec.
- Partial object — shallow-merge fields; use a function value to replace a field.
effect field — a unary function (previous) => next updates the prior worker /
supervised body; a multi-argument function value replaces effect outright (queue workers
stay two-argument).
- Full reducer —
(previous) => next over the whole spec (see
configureLayer
).
ConfigPatch<interface DaemonMakeOptions<E, RUser>Configuration for
Daemon.make
when using the config-object form (id is separate).
DaemonMakeOptions<function (type parameter) E in DaemonServiceDefinition<Self, Id extends string, E, R>E, function (type parameter) R in DaemonServiceDefinition<Self, Id extends string, E, R>R>>,
) => 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<never>;
/**
* Patch only the supervised repeat `effect`: `fn(previous) => next`.
*/
readonly DaemonServiceDefinition<Self, Id extends string, E, R>.wrapEffect: (fn: (previous: DaemonMakeOptions<E, R>["effect"]) => DaemonMakeOptions<E, R>["effect"]) => Layer.Layer<never>Patch only the supervised repeat effect: fn(previous) => next.
wrapEffect: (
fn: (
previous: DaemonMakeOptions<E, R>["effect"]
) => DaemonMakeOptions<E, R>["effect"]
fn: (
previous: DaemonMakeOptions<E, R>["effect"](parameter) previous: {
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;
}
previous: interface DaemonMakeOptions<E, RUser>Configuration for
Daemon.make
when using the config-object form (id is separate).
DaemonMakeOptions<function (type parameter) E in DaemonServiceDefinition<Self, Id extends string, E, R>E, function (type parameter) R in DaemonServiceDefinition<Self, Id extends string, E, R>R>["effect"],
) => interface DaemonMakeOptions<E, RUser>Configuration for
Daemon.make
when using the config-object form (id is separate).
DaemonMakeOptions<function (type parameter) E in DaemonServiceDefinition<Self, Id extends string, E, R>E, function (type parameter) R in DaemonServiceDefinition<Self, Id extends string, E, R>R>["effect"],
) => 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<never>;
/**
* {@link Daemon} built from {@link defaultSpec} after folding configure patches.
* Hyperlink uses this when assembling the group runtime.
*/
readonly DaemonServiceDefinition<Self, Id extends string, E, R>.buildConfiguredDaemon: Effect.Effect<Daemon<R>>(property) DaemonServiceDefinition<Self, Id extends string, E, R>.buildConfiguredDaemon: {
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;
}
Daemon
built from
defaultSpec
after folding configure patches.
Hyperlink uses this when assembling the group runtime.
buildConfiguredDaemon: 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<interface Daemon<out R>Managed daemon handle for Hyperlink supervision.
Daemon<function (type parameter) R in DaemonServiceDefinition<Self, Id extends string, E, R>R>>;
}