(chime-ch times)
(chime-ch times {:keys [buffer error-handler on-finished clock drop-overruns?]})
Returns a read-only (core.async) channel that 'chimes' at every time in the <times> list.
Arguments:
times - (required) Sequence of java.util.Dates, java.time.Instant, java.time.ZonedDateTime, java.time.OffsetDateTime,
or msecs since epoch. Consumers of the returned channel will receive these as Instant
objects.
buffer - (optional but STRONGLY advised) Buffering semantics for the underlying write-channel.
Allows for finer control (than :drop-overruns?
) wrt what happens with over-runnning jobs (i.e. dropped/slided)
error-handler - (optional) See chime-at
on-finished - (optional) See chime-at
clock - (optional) See chime-at
drop-overruns? - (optional) See chime-at
(prefer :buffer
if you're not sure consumers can keep up with the schedule)
Usage:
(let [now (Instant/now) chimes (chime-ch [(.plusSeconds now -2) ; in the past - will be dropped (per :drop-overruns?). (.plusSeconds now 2) (.plusSeconds now 4)] {:drop-overruns? true})] (go-loop [] ;; fast consumer (when-let [msg (<! chimes)] (prn "Chiming at:" msg) (recur))))
There are extensive usage examples in the README
Returns a read-only (core.async) channel that 'chimes' at every time in the <times> list. Arguments: times - (required) Sequence of java.util.Dates, java.time.Instant, java.time.ZonedDateTime, java.time.OffsetDateTime, or msecs since epoch. Consumers of the returned channel will receive these as `Instant` objects. buffer - (optional but STRONGLY advised) Buffering semantics for the underlying write-channel. Allows for finer control (than `:drop-overruns?`) wrt what happens with over-runnning jobs (i.e. dropped/slided) error-handler - (optional) See `chime-at` on-finished - (optional) See `chime-at` clock - (optional) See `chime-at` drop-overruns? - (optional) See `chime-at` (prefer `:buffer` if you're not sure consumers can keep up with the schedule) Usage: (let [now (Instant/now) chimes (chime-ch [(.plusSeconds now -2) ; in the past - will be dropped (per :drop-overruns?). (.plusSeconds now 2) (.plusSeconds now 4)] {:drop-overruns? true})] (go-loop [] ;; fast consumer (when-let [msg (<! chimes)] (prn "Chiming at:" msg) (recur)))) There are extensive usage examples in the README
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close