aboutsummaryrefslogtreecommitdiffstats
path: root/packages/plugins/queue-restate/src/service.ts
blob: 139e5738f04eb31fd15510d25b6cf1cb42875a97 (plain) (blame)
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),
  };
}