Liking cljdoc? Tell your friends :D
Clojure only.

agentti.schedules


build-times!clj

(build-times! {:keys [interval-ms jitter-frac jitter-ms]})

Construct a Chime-compatible time sequence for a periodic task.

Returns a map with: :times a lazy, infinite sequence of java.time.Instants suitable for use with chime/chime-at :next-eta* an atom containing the epoch-millis of the next scheduled tick :jitter-ms the effective jitter in milliseconds (after validation)

Options map: :interval-ms (required) Base interval between executions, in milliseconds. Must be positive.

:jitter-ms (optional) Maximum jitter in milliseconds. Each execution time is offset by a random amount within the allowed jitter range. Must satisfy 0 <= jitter-ms < interval-ms.

:jitter-frac (optional) Fractional jitter relative to the interval (e.g. 0.1 for ±10%). Mutually exclusive with :jitter-ms. Must satisfy 0.0 <= jitter-frac < 1.0.

If neither :jitter-ms nor :jitter-frac is provided, executions occur at a fixed interval with no jitter.

The returned :times sequence is intended to be passed directly to chime/chime-at. The :next-eta* atom can be used for monitoring or administrative interfaces to display the next scheduled execution time.

Construct a Chime-compatible time sequence for a periodic task.

Returns a map with:
  :times      a lazy, infinite sequence of `java.time.Instant`s suitable
              for use with `chime/chime-at`
  :next-eta*  an atom containing the epoch-millis of the next scheduled tick
  :jitter-ms  the effective jitter in milliseconds (after validation)

Options map:
  :interval-ms  (required)
      Base interval between executions, in milliseconds. Must be positive.

  :jitter-ms    (optional)
      Maximum jitter in milliseconds. Each execution time is offset by a
      random amount within the allowed jitter range. Must satisfy
      0 <= jitter-ms < interval-ms.

  :jitter-frac  (optional)
      Fractional jitter relative to the interval (e.g. 0.1 for ±10%).
      Mutually exclusive with :jitter-ms. Must satisfy 0.0 <= jitter-frac < 1.0.

If neither :jitter-ms nor :jitter-frac is provided, executions occur at a
fixed interval with no jitter.

The returned `:times` sequence is intended to be passed directly to
`chime/chime-at`. The `:next-eta*` atom can be used for monitoring or
administrative interfaces to display the next scheduled execution time.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close