mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-25 10:28:01 +00:00
refactor(db): isolate test hooks and clean up workflow worker options
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { prisma } from '@shumai/db'
|
||||
import { setupTestDbHooks } from '@shumai/db'
|
||||
import { setupTestDbHooks } from '@shumai/db/test'
|
||||
import {
|
||||
updateTaskStatusActivity,
|
||||
updateAssetStatusActivity,
|
||||
|
||||
@@ -5,6 +5,10 @@ export async function getTranscodeWorkerQueueActivity(): Promise<string> {
|
||||
return 'transcode_queue'
|
||||
}
|
||||
|
||||
export async function getAgentWorkerQueueActivity(): Promise<string> {
|
||||
return 'agent_queue'
|
||||
}
|
||||
|
||||
export async function getAssetStatusActivity(params: { assetId: string }): Promise<AssetStatus | null> {
|
||||
const asset = await prisma.asset.findUnique({
|
||||
where: { id: params.assetId },
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, it, expect, beforeEach, vi } from 'vitest'
|
||||
import { prisma } from '@shumai/db'
|
||||
import { setupTestDbHooks } from '@shumai/db'
|
||||
import { setupTestDbHooks } from '@shumai/db/test'
|
||||
import { workflowService } from './workflow'
|
||||
import { LocalExecutor, ConcurrencyLimiter, registerWorkflow } from './local-executor'
|
||||
import { WorkflowTaskStatus, WorkflowTaskType } from '@shumai/db'
|
||||
|
||||
@@ -56,15 +56,7 @@ export class WorkflowService {
|
||||
}
|
||||
|
||||
// Starts Temporal workers for specific task queues
|
||||
async startWorkers(
|
||||
queue: string,
|
||||
options?: {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
workflowBundle?: any
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
activities?: any
|
||||
},
|
||||
): Promise<void> {
|
||||
async startWorkers(queue: string): Promise<void> {
|
||||
const type = process.env.WORKFLOW_EXECUTOR || 'local'
|
||||
if (type === 'temporal') {
|
||||
const { Worker, NativeConnection } = await import('@temporalio/worker')
|
||||
@@ -74,8 +66,7 @@ export class WorkflowService {
|
||||
})
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const activities = options?.activities || (globalThis as any).__localActivities
|
||||
const workflowBundle = options?.workflowBundle
|
||||
const activities = (globalThis as any).__localActivities
|
||||
|
||||
// For agent_queue and transcode_queue, use worker-specific unique queues
|
||||
const crypto = await import('crypto')
|
||||
@@ -96,7 +87,6 @@ export class WorkflowService {
|
||||
|
||||
const sharedWorker = await Worker.create({
|
||||
connection,
|
||||
workflowBundle,
|
||||
activities: sharedActivities,
|
||||
taskQueue: queue,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user