Hyperlinkv0.9.0-beta.0

Daemon

Daemon.Tagconstsrc/Daemon.ts:2266
<Self>(): DaemonTagBuild<Self>

Define a managed daemon as a toolkit HyperService. Self is given explicitly (Effect's () two-stage form). The base tag carries observation + lifecycle; add a schedule with .pipe(schedule(…)). Declare value/error wire schemas on the tag:

class Health extends Daemon.Tag<Health>()("app/Health") {}

class Prices extends Daemon.Tag<Prices>()("app/Prices", PriceSchema) {}

class PricesE extends Daemon.Tag<PricesE>()("app/Prices", PriceSchema, FetchErr) {}

class PricesCfg extends Daemon.Tag<PricesCfg>()("app/Prices", {
  success: PriceSchema,
  error: FetchErr,
}) {}

Pass options.node to bind the daemon to a Node.Tag.

constructorsscheduleNode.Tag
Source src/Daemon.ts:226627 lines
export const Tag = <Self>() => {
  function build(
    key: string,
    second?: Schema.Top | DaemonTagOptions,
    third?: Schema.Top,
  ): HyperlinkTag<Self, DaemonSpec> | NodeBoundTag<Self, DaemonSpec, unknown> {
    if (second === undefined) {
      return buildDaemonTag<Self>(key, undefined);
    }
    if (Schema.isSchema(second)) {
      return buildDaemonTag<Self>(key, undefined, {
        success: second,
        error: third,
      });
    }
    if (isDaemonTagOptions(second)) {
      return buildDaemonTag<Self>(key, second);
    }
    return buildDaemonTag<Self>(key, undefined);
  }
  // The single, guarded cast: an overloaded *function* (`build`) isn't structurally assignable to a
  // call-signature *object* type (`DaemonTagBuild<Self>`) even when it implements exactly those
  // overloads — a known TS limitation (the same class as WorkPool's `nameQueueService` cast).
  // It's soundness-guarded: `daemon-driver` / `daemon-contract-shape` .test-d.ts exercise
  // `Daemon.Tag()` in every form, so a drift between `build` and `DaemonTagBuild` fails the build.
  return build as DaemonTagBuild<Self>;
};