Skip to main content

Infrastructure Snapshot Store

Description

Stores snapshots of Event Sourced Aggregates to optimize state reconstruction by reducing the number of events that need to be replayed.

Definition Schema

The definition for a infrastructure_snapshot_store component expects the following structure:

{
"example": {
"aggregate_id_type_str": "uuid.UUID",
"base_interface_module": "castlecraft_engineer.abstractions.snapshot_store",
"base_interface_name": "SnapshotStore",
"base_test_class_module": "castlecraft_engineer.testing.snapshot_store",
"base_test_class_name": "BaseSnapshotStoreTest",
"description": "An in-memory snapshot store for Ticket aggregates.",
"snapshot_module_str": "app_root_name.domain.ticketing.models.ticket_snapshot",
"snapshot_type_str": "TicketSnapshot",
"snapshot_wrapper_module": "castlecraft_engineer.abstractions.snapshot",
"snapshot_wrapper_name": "Snapshot",
"store_name": "InMemoryTicketSnapshotStore",
"store_type": "in_memory"
},
"properties": {
"store_name": {
"description": "Name of the snapshot store class (e.g., 'InMemoryTicketSnapshotStore')",
"title": "Store Name",
"type": "string"
},
"aggregate_id_type_str": {
"description": "Type hint for the aggregate's ID (e.g., 'uuid.UUID')",
"title": "Aggregate Id Type Str",
"type": "string"
},
"snapshot_type_str": {
"description": "Name of the class representing the snapshot's data/state (e.g., 'TicketSnapshotData')",
"title": "Snapshot Type Str",
"type": "string"
},
"snapshot_module_str": {
"description": "Full module path to the Snapshot data class (e.g., 'app_root_name.domain.ticketing.models.snapshots')",
"title": "Snapshot Module Str",
"type": "string"
},
"base_interface_name": {
"default": "SnapshotStore",
"description": "Name of the base SnapshotStore interface.",
"title": "Base Interface Name",
"type": "string"
},
"base_interface_module": {
"default": "castlecraft_engineer.abstractions.snapshot_store",
"description": "Module for the base SnapshotStore interface.",
"title": "Base Interface Module",
"type": "string"
},
"snapshot_wrapper_name": {
"default": "Snapshot",
"description": "Name of the Snapshot wrapper class.",
"title": "Snapshot Wrapper Name",
"type": "string"
},
"snapshot_wrapper_module": {
"default": "castlecraft_engineer.abstractions.snapshot",
"description": "Module for the Snapshot wrapper class.",
"title": "Snapshot Wrapper Module",
"type": "string"
},
"base_test_class_name": {
"default": "BaseSnapshotStoreTest",
"description": "Name of the base test class for snapshot stores.",
"title": "Base Test Class Name",
"type": "string"
},
"base_test_class_module": {
"default": "castlecraft_engineer.testing.snapshot_store",
"description": "Module for the base test class.",
"title": "Base Test Class Module",
"type": "string"
},
"store_type": {
"default": "in_memory",
"description": "Type of store to generate (e.g., 'in_memory'). Controls internal implementation.",
"title": "Store Type",
"type": "string"
},
"description": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Optional description for the snapshot store.",
"title": "Description"
}
},
"required": [
"store_name",
"aggregate_id_type_str",
"snapshot_type_str",
"snapshot_module_str"
],
"title": "SnapshotStoreEngineInputDTO",
"type": "object"
}

Naming and Location Conventions

Class: PascalCase, typically ends with 'SnapshotStore'. File: ${infrastructure_snapshot_store_name}.py (based on ${infrastructure_snapshot_store_name}). Location: app/infrastructure/snapshot_stores.

Example Definition

{
"store_name": "InMemoryTicketSnapshotStore",
"aggregate_id_type_str": "uuid.UUID",
"snapshot_type_str": "TicketSnapshot",
"snapshot_module_str": "app_root_name.domain.ticketing.models.ticket_snapshot",
"base_interface_name": "SnapshotStore",
"base_interface_module": "castlecraft_engineer.abstractions.snapshot_store",
"snapshot_wrapper_name": "Snapshot",
"snapshot_wrapper_module": "castlecraft_engineer.abstractions.snapshot",
"base_test_class_name": "BaseSnapshotStoreTest",
"base_test_class_module": "castlecraft_engineer.testing.snapshot_store",
"store_type": "in_memory",
"description": "An in-memory snapshot store for Ticket aggregates."
}