Idiomatic API for working with Chronicle observers.
An observer is a reactor, reducer, or projection registered against an event sequence to be told about the events it cares about. This module is how an application finds out what the event store knows about its observers, and how it removes one whose declaring code is gone.
Mirrors the C#, Kotlin, and TypeScript clients' IObservers.
Options
:client— the client name (default:Chronicle.Client):namespace— accepted for consistency with other APIs and ignored here
Summary
Types
What happened to a requested partition recovery.
Functions
Releases the quarantine of a whole observer. Accepts an observer id or a reactor/reducer module.
Releases a quarantined partition of an observer, optionally retrying it straight away.
Fast forwards an observer to the tail of its event sequence.
Gets every observer registered in the event store's current namespace.
Removes an observer and everything keyed to it.
Retries a failed partition of an observer.
Types
Functions
Releases the quarantine of a whole observer. Accepts an observer id or a reactor/reducer module.
@spec clear_partition_quarantine(String.t() | module(), String.t(), keyword()) :: {:ok, %{outcome: atom(), retry_outcome: retry_outcome()}} | {:error, term()}
Releases a quarantined partition of an observer, optionally retrying it straight away.
Options: :retry_immediately (default true), plus the common options.
Returns {:ok, %{outcome: :cleared | :not_found | :not_quarantined, retry_outcome: outcome}}
where retry_outcome is a retry_outcome/0. Mirrors .NET's
ClearFailedPartitionQuarantineFor<TReactor>(partition, retryImmediately).
@spec fast_forward(String.t(), keyword()) :: {:ok, Chronicle.Observers.FastForwardResult.t()} | {:error, term()}
Fast forwards an observer to the tail of its event sequence.
Every event the observer has not yet handled is skipped without invoking it, and its failed partitions are discarded. State it has already built is kept, so the effect of the skipped events is missing from it; replay the observer instead to rebuild.
Returns a FastForwardResult saying what happened and where the observer is now. An observer
that is replaying is left alone and reported as :replaying.
@spec get_all(keyword()) :: {:ok, [Chronicle.Observers.ObserverInformation.t()]} | {:error, term()}
Gets every observer registered in the event store's current namespace.
@spec remove(String.t(), keyword()) :: {:ok, Chronicle.Observers.RemovalResult.t()} | {:error, term()}
Removes an observer and everything keyed to it.
For the observer whose declaring code is gone — a read model and its projection that were
deleted, a reactor that was removed. The observer it registered stays behind, settles into
:disconnected, and keeps its records in the event store forever.
Removal covers the whole event store, because an observer's definition is a store-level record. It refuses while the observer is running or has a subscribed client in any namespace, so what it can remove is only ever an observer no client is reporting — stop the declaring application first if you mean to remove a live one. Read model data and sink containers are left untouched.
@spec retry_partition(String.t() | module(), String.t(), keyword()) :: {:ok, retry_outcome()} | {:error, term()}
Retries a failed partition of an observer.
observer is the observer id, or a reactor/reducer module. Mirrors .NET's
RetryFailedPartitionFor<TReactor>(partition).
Returns {:ok, outcome} where outcome is :started (a recovery was started or resumed),
:partition_not_found (nothing failed there), :observer_quarantined or :partition_quarantined
(clear the quarantine first, see clear_partition_quarantine/3).