andreo/eventsauce-snapshotting
Extended snapshotting components for EventSauce: Doctrine DBAL snapshot repository plus versioned snapshotting support. Includes version-aware aggregate repository, snapshot version inflector/comparator, and VersionedSnapshotState for evolving snapshot schemas on PHP 8.2+.
VersionedSnapshotState), enabling backward/forward compatibility—a critical feature for long-lived aggregates.doctrine/dbal package.SnapshotVersionInflector or SnapshotVersionComparator implementations could break aggregate reconstitution.ConditionalSnapshotStrategy (e.g., EveryNEventConditionalSnapshotStrategy) may lead to inconsistent snapshots or performance degradation.EveryNEventConditionalSnapshotStrategy impact replay speed vs. storage size?AggregateRootWithSnapshotting.DoctrineSnapshotRepository with a dedicated snapshot table.VersionedSnapshotState for aggregates needing schema evolution.AggregateRootRepositoryWithSnapshotting in AggregateRootRepositoryWithConditionalSnapshot for strategic snapshot storage.php artisan snapshot:prune).UuidEncoder.AggregateRootBehaviour.DoctrineSnapshotRepository and SnapshotStateSerializer.VersionedSnapshotState for aggregates with evolving schemas.SnapshotVersionInflector and SnapshotVersionComparator.EveryNEventConditionalSnapshotStrategy or custom logic.SnapshotState classes and migration of snapshot tables.EveryNEvent) require tuning based on aggregate behavior.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Snapshot version mismatch | Aggregate reconstitution fails with assert errors. |
Use SnapshotVersionComparator to enforce compatibility. |
| DBAL connection issues | Snapshots unavailable; aggregates load all events. | Implement retries and circuit breakers for DBAL operations. |
| Corrupt snapshot data | Aggregate state becomes inconsistent. | Add data validation in reconstituteFromSnapshotState. |
| Conditional strategy misconfiguration | Snapshots stored too frequently/sparingly, degrading performance. | Monitor snapshot frequency and adjust EveryNEventConditionalSnapshotStrategy. |
| EventSauce event bus failure | Snapshots stored but aggregates fail to load. | Ensure event bus resilience (e.g., dead-letter queues). |
| Laravel cache invalidation | Snapshots not invalidated on aggregate changes (if cached). | Avoid caching snapshots; rely on database consistency. |
How can I help you explore Laravel packages today?