Skip to content

Commit

Permalink
refactor: Add deletePackData type and update embedderWorkerPlugin to …
Browse files Browse the repository at this point in the history
…handle deletePack job
  • Loading branch information
HaruHunab1320 committed Jul 5, 2024
1 parent c180f4e commit 952363f
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions packages/embedder/worker/src/lib/embedder-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { err, info } from '@magickml/embedder-config'
import {
processEmbedJob,
processDeleteLoaderJob,
processDeletePackJob,
} from '@magickml/embedder-queue'
import { Worker } from 'bullmq'
import { defineNitroPlugin } from 'nitropack/runtime'
Expand All @@ -22,11 +23,12 @@ export const embedderWorkerPlugin = defineNitroPlugin(() => {

type ProcessJobData = { jobId: string }
type DeleteLoaderData = { loaderId: string; path: string }
type DeletePackData = { packId: string }

const worker = new Worker<
ProcessJobData | DeleteLoaderData,
ProcessJobData | DeleteLoaderData | DeletePackData,
void,
'processJob' | 'deleteLoader'
'processJob' | 'deleteLoader' | 'deletePack'
>(
queueName,
async job => {
Expand All @@ -46,6 +48,14 @@ export const embedderWorkerPlugin = defineNitroPlugin(() => {
} catch (error) {
err(`Error deleting loader ${loaderId}`, error)
}
} else if (job.name === 'deletePack') {
const { packId } = job.data as DeletePackData
console.log(`Deleting pack ${packId}`)
try {
await processDeletePackJob(packId)
} catch (error) {
err(`Error deleting pack ${packId}`, error)
}
}
},
{ connection }
Expand Down

0 comments on commit 952363f

Please sign in to comment.