Repository navigation
Release v3.19.0
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 EventTypemarks a reactor or reducer function as a batch function; repeat it once per event type. A reactor batch function receives anChronicle.Observers.EventBatchand aBatchContext; a reducer batch function is called once per event source with the events, the current state and aBatchContext.EventBatch.fail/3andEventBatch.defer/3settle one event source of a batch without failing the rest;deferasks Chronicle to deliver it again after a delay.BatchContexttells 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 onusesets 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 orreduce/3. - Registration fails with a clear error when an event type reaches more than one function, when
@observesis on a per-event callback, when a batch function observes an unregistered event type, or when a reducer mixes the two modes. Chronicle.Testingruns 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.