@penkov/tasks_queue
Version:
A lightweight PostgreSQL-backed task queue system with scheduling, retries, backoff strategies, and priority handling. Designed for efficiency and observability in modern Node.js applications.
18 lines (17 loc) • 582 B
JavaScript
import { TasksWorker } from "./tasks-worker.js";
export class DecoratedMethodWorker extends TasksWorker {
instance;
methodName;
constructor(instance, methodName) {
super();
this.instance = instance;
this.methodName = methodName;
}
async process(payload, context) {
const method = this.instance[this.methodName];
if (typeof method !== "function") {
throw new Error(`Decorated handler method '${this.methodName}' is not a function`);
}
await method.call(this.instance, payload, context);
}
}