evoq_aggregate_lifespan_default (evoq v1.12.0)

View Source

Default aggregate lifespan implementation.

Provides sensible defaults for aggregate lifecycle: - 30-minute idle timeout - 5-minute timeout on errors - Automatic snapshot on passivation

This prevents the memory explosion that occurs when aggregates live indefinitely (as in Commanded's default lifespan).

Summary

Functions

Return timeout after processing a command. Resets the idle timer to the default 30 minutes.

Return timeout after an error. Uses a shorter timeout (5 minutes) to allow faster recovery.

Return timeout after processing an event. Resets the idle timer to the default 30 minutes.

Return snapshot data on passivation.

Handle timeout by passivating with snapshot.

Functions

after_command(Command)

-spec after_command(map()) -> evoq_aggregate_lifespan:action().

Return timeout after processing a command. Resets the idle timer to the default 30 minutes.

after_error(Error)

-spec after_error(term()) -> evoq_aggregate_lifespan:action().

Return timeout after an error. Uses a shorter timeout (5 minutes) to allow faster recovery.

after_event(Event)

-spec after_event(map()) -> evoq_aggregate_lifespan:action().

Return timeout after processing an event. Resets the idle timer to the default 30 minutes.

on_passivate(State)

-spec on_passivate(term()) -> {ok, term()}.

Return snapshot data on passivation.

on_timeout(State)

-spec on_timeout(term()) -> {snapshot, passivate}.

Handle timeout by passivating with snapshot.