feat(persistence): one-call RegisterPersistence and managed directories#71
Merged
Conversation
SquidStdOptions.Directories declares directories created at bootstrap creation; DirectoriesConfig.RegisterDirectory (string and enum overloads) adds and creates a managed directory imperatively, idempotently, and returns its path.
…lizer registration RegisterPersistence wires registry (with recorded entity registrations applied on first resolution), journal, snapshot service and the persistence lifecycle service, config-first style: explicit instance or eager persistence YAML section, save directory defaulting to the managed save directory. RegisterMessagePackSerializer registers the MessagePack serializer for both serialization interfaces.
… ordering fix Documents RegisterPersistence and the managed save directory, the Directories options and RegisterDirectory API, and corrects the stale UsePlugins-before-ConfigureLogging constraint left over from the pre-config-first flow.
| var effective = resolver.Resolve<PersistenceConfig>(); | ||
|
|
||
| return new BinaryJournalService( | ||
| Path.Combine(ResolveSaveDirectory(resolver, effective), effective.JournalFileName), |
|
|
||
| var path = config.RegisterDirectory("scripts"); | ||
|
|
||
| Assert.Equal(Path.Combine(root.Path, "scripts"), path); |
|
|
||
| var path = config.RegisterDirectory("SavedGames"); | ||
|
|
||
| Assert.Equal(Path.Combine(root.Path, "saved_games"), path); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SquidStdOptions.Directories = ["scripts", "save"]creates them at bootstrap creation;DirectoriesConfig.RegisterDirectory(string|enum)adds and creates a managed directory imperatively (idempotent, snake_case, returns the path) - usable from plugins and modules.RegisterPersistence(PersistenceConfig? config = null): one call wires the whole persistence stack - entity registry (recordedRegisterPersistedEntityentries applied automatically on first resolution, no more manualApplyPersistedEntityRegistrations), journal and snapshot services resolved from the effective config, andIPersistenceServiceas a lifecycle service (snapshot load + journal replay at start, autosave loop, final snapshot at stop - all pre-existing behavior, now just wired). Config-first:persistenceYAML section or explicit instance (file ignored).SaveDirectorydefaults to the managedsavedirectory. Fail-fast guard when noIDataSerializeris registered.RegisterMessagePackSerializer()in SquidStd.Persistence.MessagePack (Keep semantics, mirrorsRegisterDataSerializer).Test plan