Hyperlinkv0.8.0-beta.28

RunHyperlink

RunHyperlink.Tagconstsrc/RunHyperlink.ts:572
<Self>(): {
  (key: string): RunTagWithStaticRun<
    Self,
    typeof Schema.Void,
    typeof Schema.Void,
    typeof Schema.Never
  >
  <
    I extends Schema.Top,
    A extends Schema.Top,
    E extends Schema.Top = Schema.Never
  >(
    key: string,
    config: RunHyperlinkTagSchemas<I, A, E>
  ): RunTagWithStaticRun<Self, I, A, E>
  <I extends Schema.Top, A extends Schema.Top>(
    key: string,
    payload: I,
    success: A,
    options?: { readonly description?: string }
  ): RunTagWithStaticRun<Self, I, A, typeof Schema.Never>
  <I extends Schema.Top, A extends Schema.Top, E extends Schema.Top>(
    key: string,
    payload: I,
    success: A,
    error: E,
    options?: { readonly description?: string }
  ): RunTagWithStaticRun<Self, I, A, E>
}

Define a run (concurrency-gated effect) as a named service Tag: class Backup extends RunHyperlink.Tag<Backup>()("@app/Backup", { payload: ArgsSchema }) {}. The class is the Tag — yield* Backup resolves the RunHyperlink handle (its .run applies the bounded-concurrency gate inline), while layer provides it and serve exposes it over RPC. payload is the argument schema; optional success / error declare the result and failure wire schemas.

constructorsTagRunHyperlinklayerserve
const runTag = <Self>() => {
  function build(key: string): RunTagWithStaticRun<Self, typeof Schema.Void, typeof Schema.Void, typeof Schema.Never>;
  function build<
    I extends Schema.Top,
    A extends Schema.Top,
    E extends Schema.Top = typeof Schema.Never,
  >(
    key: string,
    config: RunHyperlinkTagSchemas<I, A, E>,
  ): RunTagWithStaticRun<Self, I, A, E>;
  function build<I extends Schema.Top, A extends Schema.Top>(
    key: string,
    payload: I,
    success: A,
    options?: { readonly description?: string },
  ): RunTagWithStaticRun<Self, I, A, typeof Schema.Never>;
  function build<
    I extends Schema.Top,
    A extends Schema.Top,
    E extends Schema.Top,
  >(
    key: string,
    payload: I,
    success: A,
    error: E,
    options?: { readonly description?: string },
  ): RunTagWithStaticRun<Self, I, A, E>;
  function build(
    key: string,
    inputOrSchemas?: Schema.Top | RunHyperlinkTagSchemas,
    success?: Schema.Top,
    errorOrOptions?: Schema.Top | { readonly description?: string },
    maybeOptions?: { readonly description?: string },
  ): any {
    if (inputOrSchemas === undefined) {
      return materializeRunTag<Self>()(key, {});
    }
    if (isRunTagSchemaConfig(inputOrSchemas)) {
      return materializeRunTag<Self>()(key, inputOrSchemas);
    }
    const payload = inputOrSchemas;
    // `Schema.isSchema` is a type guard, so the 4th positional arg narrows cleanly into either the
    // `error` schema or the trailing `{ description }` options — no cast at either branch.
    const error =
      errorOrOptions !== undefined && Schema.isSchema(errorOrOptions)
        ? errorOrOptions
        : undefined;
    const options =
      errorOrOptions !== undefined && !Schema.isSchema(errorOrOptions)
        ? errorOrOptions
        : maybeOptions;
    return materializeRunTag<Self>()(key, {
      payload,
      success: success!,
      ...(error !== undefined ? { error } : {}),
      description: options?.description,
    });
  }
  return build;
};
Referenced by 1 symbols