Hyperlinkv0.8.0-beta.28

Process

Process.schedulefunctionsrc/Process.ts:2131
(windows: ReadonlyArray<ScheduleWindow>): <Self, S extends Spec>(
  tag: HyperlinkTag<Self, S>
) => HyperlinkTag<any, S & ScheduleGroupSpec>
(source: HyperlinkTag<any, ScheduleHyperlinkSpec>): <
  Self,
  S extends Spec
>(
  tag: HyperlinkTag<Self, S>
) => HyperlinkTag<any, S>

Attach a schedule to a process (pipeable). Two forms, distinguished by argument:

  • inline windows — the process owns an in-memory schedule seeded with windows, and its contract gains the schedule verb group (entries / set / add / clear):
class Matches extends Process.Tag<Matches>()("app/Matches").pipe(
  Process.schedule([Process.window(kickoff, final)]),
) {}
  • an external Schedule — the process is gated by a shared schedule resource and gains no schedule verbs (they live on the resource, which can arm many processes at once):
class IngestScores extends Process.Tag<IngestScores>()("app/IngestScores").pipe(
  Process.schedule(SeasonSchedule),
) {}
scheduleSchedule
Source src/Process.ts:213122 lines
export function schedule(
  windows: ReadonlyArray<ScheduleWindow>,
): <Self, S extends Spec>(tag: HyperlinkTag<Self, S>) => HyperlinkTag<any, S & ScheduleGroupSpec>;
export function schedule(
  source: HyperlinkTag<any, ScheduleHyperlinkSpec>,
): <Self, S extends Spec>(tag: HyperlinkTag<Self, S>) => HyperlinkTag<any, S>;
export function schedule(
  windowsOrSource: ReadonlyArray<ScheduleWindow> | HyperlinkTag<any, any, any>,
): (tag: HyperlinkTag<any, any, any>) => HyperlinkTag<any, any, any> {
  // A type-guard (not bare `Array.isArray`) so the else-branch narrows to the tag: `Array.isArray`
  // alone won't remove a `ReadonlyArray` from the union.
  const isWindows = (
    x: ReadonlyArray<ScheduleWindow> | HyperlinkTag<any, any, any>,
  ): x is ReadonlyArray<ScheduleWindow> => Array.isArray(x);
  if (isWindows(windowsOrSource)) {
    const mode: ScheduleMode = { _tag: "inline", windows: windowsOrSource };
    return (tag) => augmentTag(tag, scheduleGroupFlat, { [scheduleModeSym]: mode });
  }
  const mode: ScheduleMode = { _tag: "reference", source: windowsOrSource };
  // reference form: shape is unchanged — just stamp the mode (identity, like `distributed`).
  return (tag) => Object.assign(tag, { [scheduleModeSym]: mode });
}