link-stack/apps/metamigo-api/worker-utils.ts

22 lines
550 B
TypeScript
Raw Normal View History

2023-02-13 12:41:30 +00:00
import * as Worker from "graphile-worker";
import { defState } from "@digiresilience/montar";
import config from "./config";
const startWorkerUtils = async (): Promise<Worker.WorkerUtils> => {
const workerUtils = await Worker.makeWorkerUtils({
connectionString: config.worker.connection,
});
return workerUtils;
};
const stopWorkerUtils = async (): Promise<void> => {
return workerUtils.release();
};
const workerUtils = defState("apiWorkerUtils", {
start: startWorkerUtils,
stop: stopWorkerUtils,
});
export default workerUtils;