SourceSpec
Type, in @jr2/orchestrator/src/pool.ts. The signature of an export, or a type that it names, names this type. The Authoring surface page lists each export. This type is not an export of @jr2/orchestrator, so a workflow module does not import it by name.
type SourceSpec<T> = {
next:
| PromiseActorLogic<SourceNextResult<T>, { active: string[] }>
| PromiseActorLogic<{ item: T | null; open: number }, { active: string[] }>
| PromiseActorLogic<T | null, { active: string[] }>
| PromiseActorLogic<null, { active: string[] }>;
wake?: EventDef;
pollEvery?: number;
};Where a Pool gets its work items: the Source. Make one with source.
Fields
next:PromiseActorLogic<SourceNextResult<T>, { active: string[]; }> | PromiseActorLogic<{ item: T | null; open: number; }, { active: string[]; }> | PromiseActorLogic<T | null, { active: string[]; }> | PromiseActorLogic<null, { active: string[]; }>Claim the next ready item. Write it as an xstate promise actor,
fromPromise(async ({ input }) => …). Its input is{ active }: the ids of the items that workers have now, which it must not give again. It must also not give again an item that a worker finished. It resolves to aSourceNextResult. The Pool calls it when the run starts, after each claim, and when a worker settles. While workers run and no item is ready, it also calls it onwakeand everypollEvery.wake(optional):EventDefAn external event, made with
defineEvent, that tells the Pool that new work is ready, for example from a webhook orjr2 send. While workers run and no item is ready, it makes the Pool callnextat once. The Pool serves it as a Gate namedsourcefor the whole run (<path>.sourcewhen the Pool is composed in another Machine). Default: none.pollEvery(optional):numberWhile workers run and no item is ready, call
nextagain after this many milliseconds. Use it for a Source whose items change while the run waits. Default: none, so the Pool callsnextagain only when a worker settles orwakecomes.