Skip to content

Release v3.19.0

Choose a tag to compare

@github-actions github-actions released this 05 Nov 10:29
1571af0

Reactors and reducers can now handle events in batches, and every observer receives pages of events from Chronicle 19.122 kernels on live delivery, catch-up, replay and retry.

Added

  • @observes EventType marks a reactor or reducer function as a batch function; repeat it once per event type. A reactor batch function receives an Chronicle.Observers.EventBatch and a BatchContext; a reducer batch function is called once per event source with the events, the current state and a BatchContext.
  • EventBatch.fail/3 and EventBatch.defer/3 settle one event source of a batch without failing the rest; defer asks Chronicle to deliver it again after a delay.
  • BatchContext tells a batch function where the page came from (:live, :catch_up, :replay, :retry), which event sources it holds and whether it can defer.
  • The batch_size: option on use sets page bounds (max_events, max_bytes, max_delay_milliseconds) and, for reducers, max_concurrency (defaults to the number of schedulers online).
  • Reactors can mix batch functions and handle/2; each event goes to exactly one of them. A reducer has either one batch function or reduce/3.
  • Registration fails with a clear error when an event type reaches more than one function, when @observes is on a per-event callback, when a batch function observes an unregistered event type, or when a reducer mixes the two modes.
  • Chronicle.Testing runs batch functions.

Changed

  • Page delivery needs a Chronicle 19.122 kernel or later. Older kernels keep delivering one event source at a time to the same handlers, and deferring a batch is refused against them.
  • A failed reactor or reducer partition now reports the event before the failure as its last handled event, so Chronicle retries from the failing event instead of skipping past it. A failed reduction no longer writes a partial read model.

See Batches for reactors and Batches for reducers.