UNPKG

n8n

Version:

n8n Workflow Automation Tool

50 lines 2.76 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.PublishedWorkflowEnqueuer = void 0; const backend_common_1 = require("@n8n/backend-common"); const config_1 = require("@n8n/config"); const db_1 = require("@n8n/db"); const decorators_1 = require("@n8n/decorators"); const di_1 = require("@n8n/di"); const workflow_publication_outbox_consumer_1 = require("../../workflows/publication/workflow-publication-outbox-consumer"); let PublishedWorkflowEnqueuer = class PublishedWorkflowEnqueuer { constructor(logger, workflowsConfig, outboxRepository, outboxConsumer) { this.logger = logger; this.workflowsConfig = workflowsConfig; this.outboxRepository = outboxRepository; this.outboxConsumer = outboxConsumer; this.logger = this.logger.scoped('workflow-publication'); } async enqueueActiveWorkflows() { await this.outboxRepository.enqueueForLeaderHandoff(); this.logger.debug('Enqueued active workflow publication records'); } async enqueueOnLeaderTakeover() { if (!this.workflowsConfig.useWorkflowPublicationService) return; await this.enqueueActiveWorkflows(); this.outboxConsumer.startPolling(); await this.outboxConsumer.drainPending(); } }; exports.PublishedWorkflowEnqueuer = PublishedWorkflowEnqueuer; __decorate([ (0, decorators_1.OnLeaderTakeover)(), __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", Promise) ], PublishedWorkflowEnqueuer.prototype, "enqueueOnLeaderTakeover", null); exports.PublishedWorkflowEnqueuer = PublishedWorkflowEnqueuer = __decorate([ (0, di_1.Service)(), __metadata("design:paramtypes", [backend_common_1.Logger, config_1.WorkflowsConfig, db_1.WorkflowPublicationOutboxRepository, workflow_publication_outbox_consumer_1.WorkflowPublicationOutboxConsumer]) ], PublishedWorkflowEnqueuer); //# sourceMappingURL=published-workflow-enqueuer.js.map