1
0
Fork 0
mirror of synced 2024-10-05 12:34:50 +13:00

Rename executeSynchronously to be a bit less confusing, as it does not execute synchronously.

This commit is contained in:
Sam Rose 2024-01-30 10:13:45 +00:00
parent 6d484ce640
commit 72d63d0c00
No known key found for this signature in database
2 changed files with 5 additions and 6 deletions

View file

@ -9,7 +9,7 @@ import * as utils from "./utils"
import env from "../environment"
import { context, db as dbCore } from "@budibase/backend-core"
import { Automation, Row, AutomationData, AutomationJob } from "@budibase/types"
import { executeSynchronously } from "../threads/automation"
import { executeInThread } from "../threads/automation"
export const TRIGGER_DEFINITIONS = definitions
const JOB_OPTS = {
@ -117,8 +117,7 @@ export async function externalTrigger(
appId: context.getAppId(),
automation,
}
const job = { data } as AutomationJob
return executeSynchronously(job)
return executeInThread({ data } as AutomationJob)
} else {
return automationQueue.add(data, JOB_OPTS)
}

View file

@ -614,7 +614,7 @@ export function execute(job: Job<AutomationData>, callback: WorkerCallback) {
})
}
export function executeSynchronously(job: Job) {
export async function executeInThread(job: Job<AutomationData>) {
const appId = job.data.event.appId
if (!appId) {
throw new Error("Unable to execute, event doesn't contain app ID.")
@ -626,10 +626,10 @@ export function executeSynchronously(job: Job) {
}, job.data.event.timeout || 12000)
})
return context.doInAppContext(appId, async () => {
return await context.doInAppContext(appId, async () => {
const envVars = await sdkUtils.getEnvironmentVariables()
// put into automation thread for whole context
return context.doInEnvironmentContext(envVars, async () => {
return await context.doInEnvironmentContext(envVars, async () => {
const automationOrchestrator = new Orchestrator(job)
return await Promise.race([
automationOrchestrator.execute(),