AtlatestRenderedmarkdown
Readme

sigil-later

Time-based task scheduling for Sigil. Provides cron expression parsing and an async task runner with cancellation.

Usage

Parsing & Matching

(sigil later) provides pure functions for working with cron expressions:

(import (sigil later))

(let ((sched (parse-cron-string "*/5 * * * *")))
  (later-matches? sched (current-second))  ; true if minute is 0, 5, 10...
  (later-next sched (current-second)))     ; next matching timestamp

Cron format: minute hour day-of-month month day-of-week

Supports *, numbers, ranges (1-5), lists (1,3,5), steps (*/5, 1-10/2), named days (MON-FRI), and named months (JAN-DEC).

Async Task Runner

(sigil later runner) spawns goroutines that sleep until the exact fire time. Each task returns a cancellable handle.

(import (sigil later runner) (sigil async))

(with-async
  ;; Recurring: fires every 5 minutes
  (later-every! "*/5 * * * *" "check-inbox"
    (lambda () (check-inbox)))

  ;; One-time: fires in 1 hour
  (let ((handle (later-after! 3600 "reminder"
                  (lambda () (send-reminder)))))
    ;; Cancel before it fires:
    (later-cancel! handle))

  ;; One-time: fires at a specific timestamp
  (later-at! 1742290200 "deadline"
    (lambda () (notify-deadline))))

API

(sigil later) — Parsing

ProcedureDescription
parse-cron-stringParse a 5-field cron string into a schedule
later-matches?Test if a timestamp matches a schedule
later-nextFind the next matching timestamp after a given time
later-schedule?Type predicate

(sigil later runner) — Execution

ProcedureDescription
later-every!Schedule a recurring task (cron string)
later-after!Schedule a one-time task after N seconds
later-at!Schedule a one-time task at a Unix timestamp
later-cancel!Cancel a scheduled task
later-handle?Type predicate for task handles

Building

sigil deps install
sigil build

Testing

sigil test

License

BSD-3-Clause