1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
import type {
Queue,
QueueOptions,
RunnerFuncs,
RunnerOptions,
} from "@karakeep/shared/queueing";
import { buildDispatcherService } from "./dispatcher";
import { buildRunnerService } from "./runner";
export interface RestateServicePair<T, R> {
dispatcher: ReturnType<typeof buildDispatcherService<T, R>>;
runner: ReturnType<typeof buildRunnerService<T, R>>;
}
export function buildRestateServices<T, R>(
queue: Queue<T>,
funcs: RunnerFuncs<T, R>,
opts: RunnerOptions<T>,
queueOpts: QueueOptions,
): RestateServicePair<T, R> {
return {
dispatcher: buildDispatcherService<T, R>(queue, opts, queueOpts),
runner: buildRunnerService<T, R>(queue.name(), funcs, opts),
};
}
|