Skip to content

Conversation

@ramonsmits
Copy link
Member

@ramonsmits ramonsmits commented Aug 30, 2023

Type safe settings instead of dictionaries

For the primary instance the settings for SC core and RavenDB persisted were resolved at various places and not only at start. This PR changes how the settings are initialized. The settings are now type-safe and initialized as early as possible.

Non-static settings init for tests

For the unittests this means settings can now easily be constructed type-safe in code as part of test arrange. This removes the need for the tests to propagate setting values to the static ConfigurationManager.AppSettings. No dependency on shared static resources in the tests where values from test A could affect test B based on their order of execution.

Deduple of persisted settings

It also removes the duplication between SC core settings and persisted specific settings. Some application persistence settings are now moved to PersisterSettings so that these only exist in one type.

TEMP folder

Tests settings no longer use the C: drive but use the TEMP folder for initializing storage folders to store artifacts created as part of running the tests.

Settings object do not have logic

While constructing the core and persisted settings for SC Primary it does not perform validation except for type validation. State validation is handled in the bootstrapper. This makes the settings behave like a DTO which makes is easier to be used for unit testing.

@ramonsmits ramonsmits self-assigned this Aug 30, 2023
@ramonsmits ramonsmits force-pushed the settings branch 2 times, most recently from efc94c1 to 97783f9 Compare September 4, 2023 14:05
@tmasternak tmasternak marked this pull request as ready for review September 4, 2023 14:06
ramonsmits and others added 25 commits September 5, 2023 14:43
…the persister specific settings can serialized to JSON for diagnostics output in the REST API
…t.ChangeType` can't convert to TimeSpan and now supports TryRead on on SettingsReader to deal with non-nulleable types
… which has its `PersisterSettings property change from Dictionary to IPersisterSettings. This allows for a persister specific implementation type to be passed as value. This means that in core for propagating settings only the `Settings` object is needed.

The `PersistenceFactory` will create a persister specific settings implementation via the resolved persister configuration type if core settings yet. This makes it easy to initialized settings type-safe in tests.
…with optional arguments for these and have the test runner pass explicit values for these removing the need to copy settings runtime values back to ConfigurationManager.AppSettings
tmasternak and others added 8 commits September 5, 2023 14:43
# Conflicts:
#	src/ServiceControl.AcceptanceTests/TestSupport/ServiceControlComponentRunner.cs
#	src/ServiceControl.Persistence.RavenDb/RavenBootstrapper.cs
…g tab indentation so aligned all files. Removed all references to c:\ and use %TEMP%
…eplacements for slash '/' and dot '.' in key names
@DavidBoike DavidBoike merged commit 58c7c2c into master Sep 5, 2023
@DavidBoike DavidBoike deleted the settings branch September 5, 2023 16:15
@DavidBoike DavidBoike added this to the 5.0.0 milestone Nov 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants