UNPKG

@unchainedshop/plugins

Version:

Official plugin collection for the Unchained Engine with payment, delivery, and pricing adapters

27 lines (26 loc) 734 B
import { WorkerAdapter, WorkerDirector } from '@unchainedshop/core'; import { setTimeout } from 'node:timers/promises'; const Heartbeat = { ...WorkerAdapter, key: 'shop.unchained.worker-plugin.heartbeat', label: 'Heartbeat plugin to check if workers are working', version: '1.0.0', type: 'HEARTBEAT', maxParallelAllocations: 1, doWork: async (input) => { if (input?.wait) { await setTimeout(input.wait); } if (input?.fails) { return { success: false, result: input, }; } return { success: true, result: input, }; }, }; WorkerDirector.registerAdapter(Heartbeat);