index.js 990 字节
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.XxlJobExecutor = void 0;
const executor_1 = require("./executor");
class XxlJobExecutor {
    executor;
    registryInterval;
    constructor(opts, jobHandlers) {
        const { executorKey, scheduleCenterUrl, accessToken, jobLogPath, } = opts;
        this.executor = new executor_1.Executor(executorKey, scheduleCenterUrl, accessToken, jobLogPath, jobHandlers);
    }
    applyMiddleware({ appType, domain }) {
        const app = this.executor.applyMiddleware({ appType, domain });
        const registry = this.executor.registry.bind(this.executor);
        registry() && (this.registryInterval = setInterval(registry, 30000));
        return app;
    }
    async close() {
        if (this.registryInterval) {
            clearInterval(this.registryInterval);
        }
        return this.executor.registryRemove();
    }
}
exports.XxlJobExecutor = XxlJobExecutor;
//# sourceMappingURL=index.js.map