A higher-level scheduler construct built on top of chime.schedule/chime-at
& clojure.core/agent
.
Remembers actively scheduled jobs, until they finish, or are manually cancelled.
A higher-level scheduler construct built on top of `chime.schedule/chime-at` & `clojure.core/agent`. Remembers actively scheduled jobs, until they finish, or are manually cancelled.
(chiming-agent)
(chiming-agent {:keys [error-handler on-finished on-aborted thread-factory]
:or {error-handler c/default-error-handler}})
Returns an agent
dressed up as a scheduler.
Can be configured with an :error-handler (2args - job-id/error), and
:on-finished (1arg - job-id) callback. The state of the agent is
a map from job-id => chime-return, and it will grow/shrink
as jobs are scheduled/un-scheduled (or finished). Use it
as the first argument to all functions in this namespace.
Returns an `agent` dressed up as a scheduler. Can be configured with an :error-handler (2args - job-id/error), and :on-finished (1arg - job-id) callback. The state of the agent is a map from job-id => chime-return, and it will grow/shrink as jobs are scheduled/un-scheduled (or finished). Use it as the first argument to all functions in this namespace.
(schedule! scheduler id->job)
Given a <scheduler> and map from ids => [job-fn times-fn], registers each job-fn (1-arg - the time) to be run per the outcome of times-fn (no-arg).
Given a <scheduler> and map from ids => [job-fn times-fn], registers each job-fn (1-arg - the time) to be run per the outcome of times-fn (no-arg).
(scheduled-ids scheduler)
Returns the ids of all the ongoing jobs of this <scheduler>, or nil if there aren't any.
Returns the ids of all the ongoing jobs of this <scheduler>, or nil if there aren't any.
(unschedule! scheduler)
(unschedule! scheduler ids)
(unschedule! scheduler dlay-millis ids)
Given a <scheduler>, gracefully un-schedules (per chime.schedule/shutdown!
)
the jobs referred to by <ids>. Triggers the :on-aborted
handler (if present)
otherwise the :on-finished
one (see scheduler
ctor).
Given a <scheduler>, gracefully un-schedules (per `chime.schedule/shutdown!`) the jobs referred to by <ids>. Triggers the `:on-aborted` handler (if present) otherwise the `:on-finished` one (see `scheduler` ctor).
(unschedule-now! scheduler)
(unschedule-now! scheduler ids)
(unschedule-now! scheduler dlay-millis ids)
Like unschedule!
, but uses chime.schedule/shutdown-now!
.
Like `unschedule!`, but uses `chime.schedule/shutdown-now!`.
(until-next-chime scheduler)
Returns a java.time.Duration
representing the (time) distance
from now (inclusive) until the next chime (exclusive) on this <scheduler>.
Returns a `java.time.Duration` representing the (time) distance from now (inclusive) until the next chime (exclusive) on this <scheduler>.
(upcoming-chime-at scheduler id)
Returns the next ZonedDateTime
object
when the job with <id> will chime.
Returns the next `ZonedDateTime` object when the job with <id> will chime.
(upcoming-chimes-at scheduler)
Returns a map from job-id => ZonedDateTime.
Returns a map from job-id => ZonedDateTime.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close