evoq_aggregate_lifespan behaviour (evoq v1.14.1)

View Source

Behavior for controlling aggregate lifecycle.

Aggregates can be configured with different lifespan strategies: - TTL-based: Passivate after idle timeout - Hibernate: Reduce memory footprint when idle - Infinite: Keep alive forever (not recommended)

The default implementation (evoq_aggregate_lifespan_default) provides sensible defaults with 30-minute TTL and automatic snapshots.

Summary

Types

action/0

-type action() :: timeout() | infinity | hibernate | stop | passivate.

Callbacks

after_command/1

-callback after_command(Command :: map()) -> action().

after_error/1

-callback after_error(Error :: term()) -> action().

after_event/1

-callback after_event(Event :: map()) -> action().

on_activate/2

(optional)
-callback on_activate(StreamId :: binary(), Snapshot :: term() | undefined) -> {ok, State :: term()}.

on_passivate/1

(optional)
-callback on_passivate(State :: term()) -> {ok, SnapshotData :: term()} | skip.

on_timeout/1

(optional)
-callback on_timeout(State :: term()) -> {ok, action()} | {snapshot, action()}.