Class DefaultModelRepository
- All Implemented Interfaces:
Namespaced<ModelRepository>, ModelAncestorResolver, ModelRepository, ModelTypeResolver
Current document-based models use their synchronously maintained direct document. Event-sourced and historical
loads use the model-stream protocol and reconstruct every selected stream at one pinned stateIndex.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionfinal classConverts a side-effect-freeCommitAttemptevaluation into one authoritative runtime commit package.static interfaceReceives a cache value and the boundaries that prove it current. -
Constructor Summary
ConstructorsConstructorDescriptionDefaultModelRepository(Client client, DocumentStore documentStore, Serializer serializer, EntityHelper entityHelper, Serializer snapshotSerializer, io.fluxzero.common.caching.Cache cache, List<io.fluxzero.common.handling.ParameterResolver<? super DeserializingMessage>> parameterResolvers) DefaultModelRepository(Client client, DocumentStore documentStore, Serializer serializer, EntityHelper entityHelper, Serializer snapshotSerializer, io.fluxzero.common.caching.Cache cache, List<io.fluxzero.common.handling.ParameterResolver<? super DeserializingMessage>> parameterResolvers, String modelNamePrefix) -
Method Summary
Modifier and TypeMethodDescriptionVerifies and adopts every staged direct Model migration known to this application.awaitGraphProjections(@NonNull Map<Class<?>, Set<String>> projections, long firstStateIndex, long stateIndex) Completes when every affected durable graph projection has processed the supplied commit range.beginLocalCommit(Collection<String> modelIds) Marks model targets as belonging to an in-flight commit from this SDK so a concurrently observed tracker update does not race the authoritative accepted result into an unnecessary cache refresh.voidconfigureModelTypes(Supplier<List<Class<?>>> modelTypes) Configures the application-bound model catalog used to version materialized Graph schemas.protected ModelRepositorycreateForNamespace(String namespace) CompletableFuture<io.fluxzero.common.api.modeling.ModelDeletionResult> deleteModel(@NonNull io.fluxzero.common.api.modeling.ModelDeletionPlan plan) Executes a previously confirmed hard-deletion plan with a new durable idempotency key.CompletableFuture<io.fluxzero.common.api.modeling.ModelDeletionResult> deleteModel(@NonNull Object modelId, @NonNull io.fluxzero.common.api.modeling.ModelDeletionCascade cascade) Hard-deletes exactly one model.CompletableFuture<io.fluxzero.common.api.modeling.ModelDeletionResult> deleteModel(@NonNull String deletionId, @NonNull io.fluxzero.common.api.modeling.ModelDeletionPlan plan) Executes or resumes a confirmed plan using an explicit durable idempotency key.CompletableFuture<io.fluxzero.common.api.modeling.ModelDeletionResult> deleteModel(@NonNull String deletionId, @NonNull Object modelId, @NonNull io.fluxzero.common.api.modeling.ModelDeletionCascade cascade) Executes or resumes an exact-model hard deletion using an explicit durable idempotency key.followPublishedEventMigration(@NonNull String migrationName, @NonNull Duration maxWait) Coordinates legacy-event reads with a migration consumer using a bounded wait before normal handler retry takes over.io.fluxzero.common.api.modeling.ModelGraphProjectionConfigurationgraphProjectionDefinition(@NonNull Class<?> modelType) Returns the application-resolved durable definition owned by this repository.io.fluxzero.common.api.modeling.ModelGraphProjectionStatusgraphProjectionStatus(@NonNull Class<?> modelType) Returns current graph-projection freshness for the supplied model type.voidinvalidateModels(Iterable<String> modelIds) Removes commit-scoped entries before a strict-policy retry reload.<T> Entity<T> Loads a model by primary ID or current alias and expected type.Loads several models at one coherent state boundary, preserving input order.loadAncestorGraph(String modelId, Class<?> modelType, Class<A> ancestorType, io.fluxzero.common.api.modeling.ModelReadBoundary boundary) Resolves and loads only the closest ancestor assignable toancestorTypeat the graph's read boundary.loadAncestorGraphs(String modelId, Class<?> modelType, Class<A> ancestorType, io.fluxzero.common.api.modeling.ModelReadBoundary boundary) Resolves every reachable ancestor assignable toancestorTypeat one boundary.loadContext(MutationPlan.Resolution resolution) Loads all direct commit targets at one state boundary.loadContext(MutationPlan.Resolution resolution, Long maxStateIndex, Map<String, Object> stagedValues, boolean includeMessageBatch) Loads a commit context with an explicit choice whether pending values from the surrounding tracking batch should be overlaid.loadContext(MutationPlan.Resolution resolution, Long maxStateIndex, Map<String, Object> stagedValues, boolean includeMessageBatch, boolean migration) <T> Entity<T> loadCurrent(@NonNull String modelId, @NonNull Class<T> modelType) Loads the latest model state by exact persisted identity.<T> Graph<T> loadGraph(@NonNull String rootId, @NonNull Class<T> rootType, @NonNull io.fluxzero.common.api.modeling.ModelReadBoundary boundary, Graph.Options options) Reconstructs one model graph at the supplied current, state, commit, event, or before boundary.<T> Graph<T> loadGraph(@NonNull String rootId, @NonNull Class<T> rootType, Graph.Options options) Reconstructs a model graph using exact persisted identity, root type, and optional caller-imposed limits.<T> Graph<T> loadGraphAtIncludingMessageBatch(@NonNull String rootId, @NonNull Class<T> rootType, long stateIndex, Graph.Options options) Reconstructs a graph at an exact durable boundary and overlays pending values from earlier messages in the current message batch.loadRebaseContext(MutationPlan.Resolution resolution, Long maxStateIndex, Map<String, Object> stagedValues, boolean includeMessageBatch, boolean migration) Reloads an ACCEPT rebase while allowing an incomplete authoritative document to advance the exact boundary.Returns the model-definition compiler shared by live commits and stored-event replay.Returns and registers the stable logical name for one concrete Model type.Class<?> Resolves a stored logical name to a registered concrete Model type.io.fluxzero.common.api.modeling.ModelDeletionPlanplanDeletion(@NonNull Object modelId, @NonNull io.fluxzero.common.api.modeling.ModelDeletionCascade cascade) Creates a bounded, non-mutating plan for an explicit model hard deletion.CompletableFuture<io.fluxzero.common.api.modeling.ModelGraphProjectionStatus> registerGraphProjection(@NonNull Class<?> modelType, boolean rebuild) Registers the graph projection declared by the supplied model type.booleansupplyCurrentModel(String modelId, Class<?> modelType, DefaultModelRepository.CurrentModelSink sink) Supplies one independently proven current cache value without allocating an intermediate result object.voidMakes accepted local model transitions immediately visible through this repository.Methods inherited from class AbstractNamespaced
close, forNamespaceMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ModelRepository
followPublishedEventMigration, forNamespace, load, load, load, load, loadCurrent, loadGraph, loadGraphAt, loadGraphAt, loadGraphAt, loadGraphBefore, registerGraphProjectionMethods inherited from interface Namespaced
forApplicationNamespace, forDefaultNamespace
-
Constructor Details
-
DefaultModelRepository
public DefaultModelRepository(Client client, DocumentStore documentStore, Serializer serializer, EntityHelper entityHelper, Serializer snapshotSerializer, io.fluxzero.common.caching.Cache cache, List<io.fluxzero.common.handling.ParameterResolver<? super DeserializingMessage>> parameterResolvers) -
DefaultModelRepository
public DefaultModelRepository(Client client, DocumentStore documentStore, Serializer serializer, EntityHelper entityHelper, Serializer snapshotSerializer, io.fluxzero.common.caching.Cache cache, List<io.fluxzero.common.handling.ParameterResolver<? super DeserializingMessage>> parameterResolvers, String modelNamePrefix)
-
-
Method Details
-
createForNamespace
- Specified by:
createForNamespacein classAbstractNamespaced<ModelRepository>
-
modelDefinitionCompiler
Returns the model-definition compiler shared by live commits and stored-event replay. -
followPublishedEventMigration
public ModelRepository followPublishedEventMigration(@NonNull @NonNull String migrationName, @NonNull @NonNull Duration maxWait) Description copied from interface:ModelRepositoryCoordinates legacy-event reads with a migration consumer using a bounded wait before normal handler retry takes over.- Specified by:
followPublishedEventMigrationin interfaceModelRepository- Parameters:
migrationName- stable durable migration-consumer namemaxWait- maximum time one read waits for the migration consumer to reach its event- Returns:
- this repository
-
planDeletion
public io.fluxzero.common.api.modeling.ModelDeletionPlan planDeletion(@NonNull @NonNull Object modelId, @NonNull @NonNull io.fluxzero.common.api.modeling.ModelDeletionCascade cascade) Description copied from interface:ModelRepositoryCreates a bounded, non-mutating plan for an explicit model hard deletion.A descendant cascade must be planned and confirmed before execution. The returned published-event count makes clear that globally published events are outside the model-stream erasure boundary.
- Specified by:
planDeletionin interfaceModelRepository
-
deleteModel
public CompletableFuture<io.fluxzero.common.api.modeling.ModelDeletionResult> deleteModel(@NonNull @NonNull Object modelId, @NonNull @NonNull io.fluxzero.common.api.modeling.ModelDeletionCascade cascade) Description copied from interface:ModelRepositoryHard-deletes exactly one model.Passing
ModelDeletionCascade.DESCENDANTSwithout a confirmed plan is rejected. UseModelRepository.deleteModel(ModelDeletionPlan)for descendant cascades.- Specified by:
deleteModelin interfaceModelRepository
-
deleteModel
public CompletableFuture<io.fluxzero.common.api.modeling.ModelDeletionResult> deleteModel(@NonNull @NonNull String deletionId, @NonNull @NonNull Object modelId, @NonNull @NonNull io.fluxzero.common.api.modeling.ModelDeletionCascade cascade) Description copied from interface:ModelRepositoryExecutes or resumes an exact-model hard deletion using an explicit durable idempotency key. Descendant deletion still requires a confirmed plan.- Specified by:
deleteModelin interfaceModelRepository
-
deleteModel
public CompletableFuture<io.fluxzero.common.api.modeling.ModelDeletionResult> deleteModel(@NonNull @NonNull io.fluxzero.common.api.modeling.ModelDeletionPlan plan) Description copied from interface:ModelRepositoryExecutes a previously confirmed hard-deletion plan with a new durable idempotency key.- Specified by:
deleteModelin interfaceModelRepository
-
deleteModel
public CompletableFuture<io.fluxzero.common.api.modeling.ModelDeletionResult> deleteModel(@NonNull @NonNull String deletionId, @NonNull @NonNull io.fluxzero.common.api.modeling.ModelDeletionPlan plan) Description copied from interface:ModelRepositoryExecutes or resumes a confirmed plan using an explicit durable idempotency key.- Specified by:
deleteModelin interfaceModelRepository
-
adoptModelMigrations
Description copied from interface:ModelRepositoryVerifies and adopts every staged direct Model migration known to this application. Materialized Graph projections declared by the application are rebuilt after every staged document has been adopted. The accepted normalized source remains isolated from later staging until the first ordinary Model write, so another legacy boundary can be re-adopted without exposing unverified state. Repeating the operation is also a safe way to resume projection rebuilds after a failure.- Specified by:
adoptModelMigrationsin interfaceModelRepository- Returns:
- the number of staged Model documents adopted by this invocation
- See Also:
-
registerGraphProjection
public CompletableFuture<io.fluxzero.common.api.modeling.ModelGraphProjectionStatus> registerGraphProjection(@NonNull @NonNull Class<?> modelType, boolean rebuild) Description copied from interface:ModelRepositoryRegisters the graph projection declared by the supplied model type.- Specified by:
registerGraphProjectionin interfaceModelRepository- Parameters:
modelType- model carrying an enabled graph projectionrebuild- whether all current roots should be scanned even if the definition is unchanged
-
configureModelTypes
-
modelName
Description copied from interface:ModelTypeResolverReturns and registers the stable logical name for one concrete Model type.- Specified by:
modelNamein interfaceModelTypeResolver
-
modelType
Description copied from interface:ModelTypeResolverResolves a stored logical name to a registered concrete Model type.- Specified by:
modelTypein interfaceModelTypeResolver
-
graphProjectionDefinition
public io.fluxzero.common.api.modeling.ModelGraphProjectionConfiguration graphProjectionDefinition(@NonNull @NonNull Class<?> modelType) Returns the application-resolved durable definition owned by this repository. -
awaitGraphProjections
-
graphProjectionStatus
public io.fluxzero.common.api.modeling.ModelGraphProjectionStatus graphProjectionStatus(@NonNull @NonNull Class<?> modelType) Description copied from interface:ModelRepositoryReturns current graph-projection freshness for the supplied model type.- Specified by:
graphProjectionStatusin interfaceModelRepository
-
load
Description copied from interface:ModelRepositoryLoads a model by primary ID or current alias and expected type. A primary model ID always takes precedence over an alias with the same value.- Specified by:
loadin interfaceModelRepository- Parameters:
modelId- persisted model key or current alias; never decorated with model type metadatamodelType- expected model type, orObjectwhen it should be resolved from storage
-
loadCurrent
public <T> Entity<T> loadCurrent(@NonNull @NonNull String modelId, @NonNull @NonNull Class<T> modelType) Description copied from interface:ModelRepositoryLoads the latest model state by exact persisted identity. Custom repositories without contextual historical reads retain their normal behavior by delegating toModelRepository.load(String, Class).- Specified by:
loadCurrentin interfaceModelRepository
-
loadAll
public <T> List<Entity<T>> loadAll(@NonNull @NonNull List<?> modelIds, @NonNull @NonNull Class<T> modelType) Description copied from interface:ModelRepositoryLoads several models at one coherent state boundary, preserving input order.Repositories without coherent multi-model reconstruction reject this capability instead of emulating it with independent reads at different boundaries.
- Specified by:
loadAllin interfaceModelRepository
-
loadGraph
public <T> Graph<T> loadGraph(@NonNull @NonNull String rootId, @NonNull @NonNull Class<T> rootType, @NonNull Graph.Options options) Description copied from interface:ModelRepositoryReconstructs a model graph using exact persisted identity, root type, and optional caller-imposed limits. Pending changes from earlier messages in the same ordered tracking segment are included.- Specified by:
loadGraphin interfaceModelRepository
-
loadGraph
public <T> Graph<T> loadGraph(@NonNull @NonNull String rootId, @NonNull @NonNull Class<T> rootType, @NonNull @NonNull io.fluxzero.common.api.modeling.ModelReadBoundary boundary, @NonNull Graph.Options options) Description copied from interface:ModelRepositoryReconstructs one model graph at the supplied current, state, commit, event, or before boundary.- Specified by:
loadGraphin interfaceModelRepository
-
loadAncestorGraph
public <A> Optional<Graph<A>> loadAncestorGraph(String modelId, Class<?> modelType, Class<A> ancestorType, io.fluxzero.common.api.modeling.ModelReadBoundary boundary) Description copied from interface:ModelAncestorResolverResolves and loads only the closest ancestor assignable toancestorTypeat the graph's read boundary. Intermediate parent values must remain unloaded.- Specified by:
loadAncestorGraphin interfaceModelAncestorResolver
-
loadAncestorGraphs
public <A> List<Graph<A>> loadAncestorGraphs(String modelId, Class<?> modelType, Class<A> ancestorType, io.fluxzero.common.api.modeling.ModelReadBoundary boundary) Description copied from interface:ModelAncestorResolverResolves every reachable ancestor assignable toancestorTypeat one boundary.The singular method remains the ergonomic default for normal graph traversal. Change subscriptions use this form because one changed model may be shared by multiple roots.
- Specified by:
loadAncestorGraphsin interfaceModelAncestorResolver
-
loadGraphAtIncludingMessageBatch
public <T> Graph<T> loadGraphAtIncludingMessageBatch(@NonNull @NonNull String rootId, @NonNull @NonNull Class<T> rootType, long stateIndex, @NonNull Graph.Options options) Reconstructs a graph at an exact durable boundary and overlays pending values from earlier messages in the current message batch. This is used by atomic model planning that must retain read-your-writes semantics without advancing beyond its already pinned durable boundary. -
loadContext
Loads all direct commit targets at one state boundary.A
nullboundary pins the current event-store state once. Historical document-model dependencies are reconstructed from stored model events; current document-model targets retain their direct-document load path.- Specified by:
loadContextin interfaceModelRepository
-
loadContext
public CommitAttempt loadContext(MutationPlan.Resolution resolution, Long maxStateIndex, Map<String, Object> stagedValues, boolean includeMessageBatch) Loads a commit context with an explicit choice whether pending values from the surrounding tracking batch should be overlaid. Automatic model handling disables this generic overlay because its preplanned batch view already supplies exactly the required predecessors; explicit operations and ordinary handlers enable it. -
loadContext
public CommitAttempt loadContext(MutationPlan.Resolution resolution, Long maxStateIndex, Map<String, Object> stagedValues, boolean includeMessageBatch, boolean migration) -
loadRebaseContext
public CommitAttempt loadRebaseContext(MutationPlan.Resolution resolution, Long maxStateIndex, Map<String, Object> stagedValues, boolean includeMessageBatch, boolean migration) Reloads an ACCEPT rebase while allowing an incomplete authoritative document to advance the exact boundary. Ordinary historical reads never enable this retry mode. -
supplyCurrentModel
public boolean supplyCurrentModel(String modelId, Class<?> modelType, DefaultModelRepository.CurrentModelSink sink) Supplies one independently proven current cache value without allocating an intermediate result object. -
updateAfterCommit
Makes accepted local model transitions immediately visible through this repository. -
beginLocalCommit
Marks model targets as belonging to an in-flight commit from this SDK so a concurrently observed tracker update does not race the authoritative accepted result into an unnecessary cache refresh.- Returns:
- an idempotent completion callback
-
invalidateModels
-