Cron and queues
Cron calls an HTTP path on a site, app or function on a schedule. Queues store asynchronous work, with retries and a dead-letter queue.
What it is
Cron calls an HTTP path on a site, app or function on a schedule. Queues store asynchronous work, with retries and a dead-letter queue.
Quick start and CLI
infaris-guard hosting schedules add --function <functionId> --path /digest --schedule "0 7 * * *"
infaris-guard hosting schedules history <cronId>
infaris-guard hosting queues create mail-jobs --consumer <functionId> --path /mail
infaris-guard hosting queues send <queueId> '{"userId":"example"}'
infaris-guard hosting queues messages <queueId> --view deadSDK and code
// Consumer function. The platform authenticates delivery to a private function.
Deno.serve(async (request: Request) => {
const job = await request.json();
// Persist an idempotency check before performing an external side effect.
console.log({ received: Boolean(job) });
return new Response(null, { status: 204 });
});Secure defaults
Queues are never public. Scope keys to send and receive. A successful 2xx completes push delivery; a failure triggers redelivery. Make consumers idempotent. Do not put personal message data in logs.
Limits
50 queues per organisation; message maximum 256 KiB, backlog 100,000. Default 5 attempts and 60 second visibility timeout. Delay maximum 7 days. Delivery does not guarantee exactly once. hosting cron manages shell cron on an own server; HTTP cron is hosting schedules.
FAQ
Task twice? A timeout can happen after processing; deduplicate by message ID. No consumer? Use receive, ack and nack with a queue key. Test cron locally? Call the handler yourself; the local stack does not execute scheduled crons.
SDK: send work from a function
Bind the producer function to the queue using --bind when creating the queue. Hosting supplies the runtime import; do not install it as a separate npm package.
// Inside a function bound to mail-jobs.
import { queue, json } from '@infaris/functions';
Deno.serve(async () => {
const sent = await queue('mail-jobs').send({ userId: 'example' });
return json({ id: sent.id });
});