Hot-Reload of all DataSourceFiles
We provide an option of using many DataSource files, and therefore for the purpose of Hot-Reloading we need to monitor all of these DataSource files. In the case that they change, Hot-Reloading means updating this collection of DataSourceFiles, and refreshing their dependencies.
The configuration file that is provided to DAB on startup may contain a property, DataSourceFiles. In a single DB scenario, this property will be null. However, in a multi-db scenario, DataSourceFiles will be a list of additional files that contain the data source information for the additional DBs.
`public DataSourceFiles? DataSourceFiles { get; init; }`
/// <summary>
/// DataSourceFiles is a record that contains a list of files defining the runtime configs for multi-db scenario.
/// SourceFiles is null for single-db scenario.
/// </summary>
/// <param name="SourceFiles">File names would match guidance as described in FileSystemRuntimeConfigLoader.cs</param>
public record DataSourceFiles(IEnumerable<string>? SourceFiles = null);
In order to correctly hot reload, we need to add file-monitoring to all of the data source files that are used as a part of a multi-db scenario, which should then trigger a hot-reload if any of those files are modified.
However, each data source file can itself contain a property DataSourceFiles, which means that we can treat the data sources that will be used in a multi-db scenario as existing in a tree structure, where the configuration file that was used to start dab is the root. We then need to file monitor that configuration file, and then parse out any of the additional files that the root config lists as DataSourceFiles. Each of those data source files then must be checked if they contain any additional data source files, and that process must repeat until we reach the data source files for which DataSourceFiles is null, the equivalent of leaves in the tree we are traversing.
When all files in the tree are being monitored, and any changes to any of them results in a hot-reload, then we will fully support hot-reloading in a multi-db scenario.