UNPKG

@unchainedshop/plugins

Version:

Because of a Typescript issue with upstream "postfinancecheckout", the Postfinance plugin has been disabled from transpilation, import the source ts files from src and enable node_module tsc or copy over the src/payment/postfinance-checkout to your projec

45 lines (37 loc) 908 B
import { IWorkerAdapter, WorkerAdapter, WorkerDirector } from '@unchainedshop/core'; const wait = async (time: number) => { return new Promise((resolve) => { setTimeout(() => { resolve(true); }, time); }); }; type Arg = { wait?: number; fails?: boolean; }; type Result = Arg; const Heartbeat: IWorkerAdapter<Arg, Result> = { ...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: Arg): Promise<{ success: boolean; result: Result }> => { if (input?.wait) { await wait(input.wait); } if (input?.fails) { return { success: false, result: input, }; } return { success: true, result: input, }; }, }; WorkerDirector.registerAdapter(Heartbeat);