"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.WorkerQueueJobCommand = exports.WorkerStartCommand = void 0;
const tslib_1 = require("tslib");
const app_1 = require("@deepkit/app");
const cli_1 = require("../cli");
const queue_1 = require("./queue");
const runner_1 = require("./runner");
const types_1 = require("./types");
let WorkerStartCommand = class WorkerStartCommand extends cli_1.CliServiceCommand {
    constructor(runner) {
        super();
        this.runner = runner;
    }
    async startService() {
        await this.runner.start();
    }
};
exports.WorkerStartCommand = WorkerStartCommand;
WorkerStartCommand.__type = [() => cli_1.CliServiceCommand, () => runner_1.WorkerRunnerService, 'runner', 'constructor', 'startService', 'WorkerStartCommand', 'P7!PP7"2#;"0$P"0%5w&'];
exports.WorkerStartCommand = WorkerStartCommand = tslib_1.__decorate([
    app_1.cli.controller('worker:start', {
        description: 'Start the worker runner'
    }),
    tslib_1.__metadata("design:paramtypes", [runner_1.WorkerRunnerService])
], WorkerStartCommand);
let WorkerQueueJobCommand = class WorkerQueueJobCommand {
    async execute(jobName, data) {
        data = data ? JSON.parse(data) : {};
        const queue = queue_1.WorkerQueueRegistry.getQueue(types_1.BaseJob.QUEUE_NAME);
        await queue.add(jobName, data);
        await queue_1.WorkerQueueRegistry.closeQueues();
    }
};
exports.WorkerQueueJobCommand = WorkerQueueJobCommand;
WorkerQueueJobCommand.__type = ['jobName', 'data', 'execute', 'WorkerQueueJobCommand', 'P&2!&2"8"0#5w$'];
exports.WorkerQueueJobCommand = WorkerQueueJobCommand = tslib_1.__decorate([
    app_1.cli.controller('worker:queue', {
        // todo: optional queue name?
        description: 'Queue a job by name'
    })
], WorkerQueueJobCommand);
//# sourceMappingURL=cli.js.map