From 9c5730003090c08d670bdf8810d80c3996ca7322 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Thu, 13 Oct 2022 17:39:26 +0100 Subject: [PATCH] Renaming some queue to automationQueue, getting build working. --- packages/backend-core/package.json | 1 + packages/backend-core/yarn.lock | 7 +++++++ packages/server/src/automations/bullboard.js | 4 ++-- packages/server/src/automations/index.js | 8 ++++---- packages/server/src/automations/triggers.js | 8 ++++---- packages/server/src/automations/utils.ts | 14 +++++++------- 6 files changed, 25 insertions(+), 17 deletions(-) diff --git a/packages/backend-core/package.json b/packages/backend-core/package.json index 404b7da346..eb90fa4159 100644 --- a/packages/backend-core/package.json +++ b/packages/backend-core/package.json @@ -64,6 +64,7 @@ }, "devDependencies": { "@types/chance": "1.1.3", + "@types/ioredis": "^4.28.10", "@types/jest": "27.5.1", "@types/koa": "2.0.52", "@types/lodash": "4.14.180", diff --git a/packages/backend-core/yarn.lock b/packages/backend-core/yarn.lock index 31d25320c7..22b93d7b3e 100644 --- a/packages/backend-core/yarn.lock +++ b/packages/backend-core/yarn.lock @@ -768,6 +768,13 @@ resolved "https://registry.yarnpkg.com/@types/http-errors/-/http-errors-1.8.2.tgz#7315b4c4c54f82d13fa61c228ec5c2ea5cc9e0e1" integrity sha512-EqX+YQxINb+MeXaIqYDASb6U6FCHbWjkj4a1CKDBks3d/QiB2+PqBLyO72vLDgAO1wUI4O+9gweRcQK11bTL/w== +"@types/ioredis@^4.28.10": + version "4.28.10" + resolved "https://registry.yarnpkg.com/@types/ioredis/-/ioredis-4.28.10.tgz#40ceb157a4141088d1394bb87c98ed09a75a06ff" + integrity sha512-69LyhUgrXdgcNDv7ogs1qXZomnfOEnSmrmMFqKgt1XMJxmoOSG/u3wYy13yACIfKuMJ8IhKgHafDO3sx19zVQQ== + dependencies: + "@types/node" "*" + "@types/istanbul-lib-coverage@*", "@types/istanbul-lib-coverage@^2.0.0", "@types/istanbul-lib-coverage@^2.0.1": version "2.0.4" resolved "https://registry.yarnpkg.com/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.4.tgz#8467d4b3c087805d63580480890791277ce35c44" diff --git a/packages/server/src/automations/bullboard.js b/packages/server/src/automations/bullboard.js index b0ccf14634..9dfa7546ec 100644 --- a/packages/server/src/automations/bullboard.js +++ b/packages/server/src/automations/bullboard.js @@ -4,7 +4,7 @@ const { KoaAdapter } = require("@bull-board/koa") const { queue } = require("@budibase/backend-core") const listeners = require("./listeners") -let automationQueue = queue.createQueue(queue.JobQueues.AUTOMATIONS) +let automationQueue = queue.createQueue(queue.JobQueue.AUTOMATIONS) listeners.addListeners(automationQueue) const PATH_PREFIX = "/bulladmin" @@ -29,4 +29,4 @@ exports.shutdown = async () => { await queue.shutdown() } -exports.queue = automationQueue +exports.automationQueue = automationQueue diff --git a/packages/server/src/automations/index.js b/packages/server/src/automations/index.js index 2baa868890..521991dd2c 100644 --- a/packages/server/src/automations/index.js +++ b/packages/server/src/automations/index.js @@ -1,5 +1,5 @@ const { processEvent } = require("./utils") -const { queue, shutdown } = require("./bullboard") +const { automationQueue, shutdown } = require("./bullboard") const { TRIGGER_DEFINITIONS, rebootTrigger } = require("./triggers") const { ACTION_DEFINITIONS } = require("./actions") @@ -8,7 +8,7 @@ const { ACTION_DEFINITIONS } = require("./actions") */ exports.init = async function () { // this promise will not complete - const promise = queue.process(async job => { + const promise = automationQueue.process(async job => { await processEvent(job) }) // on init we need to trigger any reboot automations @@ -17,13 +17,13 @@ exports.init = async function () { } exports.getQueues = () => { - return [queue] + return [automationQueue] } exports.shutdown = () => { return shutdown() } -exports.queue = queue +exports.automationQueue = automationQueue exports.TRIGGER_DEFINITIONS = TRIGGER_DEFINITIONS exports.ACTION_DEFINITIONS = ACTION_DEFINITIONS diff --git a/packages/server/src/automations/triggers.js b/packages/server/src/automations/triggers.js index 395390113a..6a4bbd8da6 100644 --- a/packages/server/src/automations/triggers.js +++ b/packages/server/src/automations/triggers.js @@ -4,7 +4,7 @@ const { coerce } = require("../utilities/rowProcessor") const { definitions } = require("./triggerInfo") const { isDevAppID } = require("../db/utils") // need this to call directly, so we can get a response -const { queue } = require("./bullboard") +const { automationQueue } = require("./bullboard") const { checkTestFlag } = require("../utilities/redis") const utils = require("./utils") const env = require("../environment") @@ -56,7 +56,7 @@ async function queueRelevantRowAutomations(event, eventType) { automationTrigger.inputs && automationTrigger.inputs.tableId === event.row.tableId ) { - await queue.add({ automation, event }, JOB_OPTS) + await automationQueue.add({ automation, event }, JOB_OPTS) } } }) @@ -110,7 +110,7 @@ exports.externalTrigger = async function ( if (getResponses) { return utils.processEvent({ data }) } else { - return queue.add(data, JOB_OPTS) + return automationQueue.add(data, JOB_OPTS) } } @@ -136,7 +136,7 @@ exports.rebootTrigger = async () => { timestamp: Date.now(), }, } - rebootEvents.push(queue.add(job, JOB_OPTS)) + rebootEvents.push(automationQueue.add(job, JOB_OPTS)) } } await Promise.all(rebootEvents) diff --git a/packages/server/src/automations/utils.ts b/packages/server/src/automations/utils.ts index 7e19486798..54b8078f30 100644 --- a/packages/server/src/automations/utils.ts +++ b/packages/server/src/automations/utils.ts @@ -1,7 +1,7 @@ import { Thread, ThreadType } from "../threads" import { definitions } from "./triggerInfo" import * as webhooks from "../api/controllers/webhook" -import { queue } from "./bullboard" +import { automationQueue } from "./bullboard" import newid from "../db/newid" import { updateEntityMetadata } from "../utilities" import { MetadataTypes, WebhookType } from "../constants" @@ -79,12 +79,12 @@ export function removeDeprecated(definitions: any) { // end the repetition and the job itself export async function disableAllCrons(appId: any) { const promises = [] - const jobs = await queue.getRepeatableJobs() + const jobs = await automationQueue.getRepeatableJobs() for (let job of jobs) { if (job.key.includes(`${appId}_cron`)) { - promises.push(queue.removeRepeatableByKey(job.key)) + promises.push(automationQueue.removeRepeatableByKey(job.key)) if (job.id) { - promises.push(queue.removeJobs(job.id)) + promises.push(automationQueue.removeJobs(job.id)) } } } @@ -92,8 +92,8 @@ export async function disableAllCrons(appId: any) { } export async function disableCron(jobId: string, jobKey: string) { - await queue.removeRepeatableByKey(jobKey) - await queue.removeJobs(jobId) + await automationQueue.removeRepeatableByKey(jobKey) + await automationQueue.removeJobs(jobId) console.log(`jobId=${jobId} disabled`) } @@ -141,7 +141,7 @@ export async function enableCronTrigger(appId: any, automation: Automation) { ) { // make a job id rather than letting Bull decide, makes it easier to handle on way out const jobId = `${appId}_cron_${newid()}` - const job: any = await queue.add( + const job: any = await automationQueue.add( { automation, event: { appId, timestamp: Date.now() },