Skip to content

Support loading configuration for plugins (DB-624)#4130

Merged
pvanbuijtene merged 1 commit intomasterfrom
timothycoleman/config
Jan 29, 2024
Merged

Support loading configuration for plugins (DB-624)#4130
pvanbuijtene merged 1 commit intomasterfrom
timothycoleman/config

Conversation

@timothycoleman
Copy link
Copy Markdown
Contributor

@timothycoleman timothycoleman commented Jan 25, 2024

Added: General support for plugin configuration

We now load the whole configuration (ClusterVNodeOptions, Metrics, Kestrel,
Logging, and any additional config json files) into a single IConfiguration object that we
add to the DI and will (shortly) make available to the plugins in ConfigureServices

The json files are loaded into the root of the IConfiguration and are expected
to put their values in the right sections. For historical reasons the metrics
config is an exception to this and is loaded into the section EventStore:Metrics

Additional config files are any json files in the following two directories:

  • DefaultConfigurationDirectory/config
  • ApplicationDirectory/config

We use the config subdirectory in each case to ensure that we don't load
other json files that are not rooted config files (*deps.json, metrics etc)

Additional config can also be set via

  • command line: --eventstore:plugins:key=value
  • environment: EventStore__Plugins__Key

Limitations: ClusterVNodeOptions cannot yet be configured in the additional json files. This is because ClusterVNodeOptions is not yet resolved out of the main IConfiguration object. (Edit: this was addressed in #4144)

@timothycoleman timothycoleman changed the title WIP: rejig some configuration Support loading configuration for plugins Jan 29, 2024
@timothycoleman timothycoleman changed the title Support loading configuration for plugins Support loading configuration for plugins (DB-624) Jan 29, 2024
@linear
Copy link
Copy Markdown

linear Bot commented Jan 29, 2024

@timothycoleman timothycoleman marked this pull request as ready for review January 29, 2024 11:10
Comment thread src/EventStore.ClusterNode/Program.cs Outdated
Comment thread src/EventStore.ClusterNode/Program.cs Outdated
Comment thread src/EventStore.ClusterNode/Program.cs
bool optional = false,
bool reloadOnChange = false) {

if (!Locations.TryLocateConfigFile(configFilePath, out var directory, out var fileName)) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function hides this custom behaviour that tries to locate the files in yet another path.
We should consider passing the path to the function upfront.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeeeah it's from the previous behviour that checks for kestrelsettings etc in two places. i'd prefer to leave that for now

Comment thread src/EventStore.Common/Configuration/ConfigurationBuilderExtensions.cs Outdated
$"Could not find {configFilePath} in the following directories: {string.Join(", ", Locations.GetPotentialConfigurationDirectories())}");
}

builder.AddJsonFile(config => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we instead pass just the filename, optional and reloadOnChange parameters?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

im not sure, i've kept it the same way as it was being called before

Comment thread src/EventStore.Common/Configuration/ConfigurationBuilderExtensions.cs Outdated
We now load the whole configuration (ClusterVNodeOptions, Metrics, Kestrel,
Logging, and any additional config json files) into a single IConfiguration object that we
add to the DI and will (shortly) make available to the plugins in ConfigureServices

The json files are loaded into the root of the IConfiguration and are expected
to put their values in the right sections. For historical reasons the metrics
config is an exception to this and is loaded into the section EventStore:Metrics

Additional config files are any json files in the following two directories:
- DefaultConfigurationDirectory/config
- ApplicationDirectory/config

We use the `config` subdirectory in each case to ensure that we don't load
other json files that are not rooted config files (*deps.json, metrics etc)

Additional config can also be set via
- command line: --eventstore:plugins:key=value
- environment: EventStore__Plugins__Key
@pvanbuijtene pvanbuijtene merged commit 62abe64 into master Jan 29, 2024
@pvanbuijtene pvanbuijtene deleted the timothycoleman/config branch January 29, 2024 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants