Fetchq Task
Let you add singleton tasks to a Fetchq queue.
👉 Each task gets executed by one single worker at the time, no matter the horizontal scalability of the queue.
You keep scaling the associated workers as so to run different tasks in parallel.
This is suitable for running stuff akin to a CRON Job.
Configuration
forrest.run({
settings: {
fetchq: {
task: {
register: [
{
subject: 'foobar',
handler: (doc) => doc.reschedule('+1m')
}
],
queue: {
name: 'foobar',
settings: {}
},
worker: {
settings: {}
}
}
}
}
})
Add Tasks
As configuration:
forrest.run({
settings: {
fetchq: {
task: {
register: [
{
subject: "cqrs-todos",
payload: { target: "todos" },
handler: (doc, ctx) => {
console.log("cqrs-todos", doc.payload);
return doc.reschedule("+1s");
}
}
]
}
}
}
})
As an extension:
const myFeature = () => [
{
target: "$FETCHQ_REGISTER_TASK",
handler: {
subject: "cqrs-todos",
payload: { target: "todos" },
handler: (doc, ctx) => {
console.log("cqrs-todos", doc.payload);
return doc.reschedule("+1s");
}
}
}
]
Task Configuration
resetOnBoot
Set it to true
and the task will be completely reset at boot time.