feat: Add support for scheduled workflows (#7651)

We still need to:
But wanted to open the PR for early feedback on the approach
This commit is contained in:
Stevche Radevski
2024-06-10 16:49:52 +02:00
committed by GitHub
parent 7f53fe06b6
commit 69410162f6
20 changed files with 465 additions and 44 deletions

View File

@@ -1,4 +1,4 @@
import { WorkflowManager } from "@medusajs/orchestration"
import { WorkflowManager, WorkflowScheduler } from "@medusajs/orchestration"
import { promiseAll } from "@medusajs/utils"
import {
createStep,
@@ -11,6 +11,24 @@ import {
} from "../.."
jest.setTimeout(30000)
import { IDistributedSchedulerStorage, SchedulerOptions } from "../../dist"
class MockSchedulerStorage implements IDistributedSchedulerStorage {
async schedule(
jobDefinition: string | { jobId: string },
schedulerOptions: SchedulerOptions
): Promise<void> {
return Promise.resolve()
}
async remove(jobId: string): Promise<void> {
return Promise.resolve()
}
async removeAll(): Promise<void> {
return Promise.resolve()
}
}
WorkflowScheduler.setStorage(new MockSchedulerStorage())
const afterEach_ = () => {
jest.clearAllMocks()