diff options
Diffstat (limited to 'plugins/VNLib.Plugins.Essentials.Content.Routing/src')
-rw-r--r-- | plugins/VNLib.Plugins.Essentials.Content.Routing/src/ManagedRouteStore.cs | 3 | ||||
-rw-r--r-- | plugins/VNLib.Plugins.Essentials.Content.Routing/src/Router.cs | 2 | ||||
-rw-r--r-- | plugins/VNLib.Plugins.Essentials.Content.Routing/src/stores/DbRouteStore.cs (renamed from plugins/VNLib.Plugins.Essentials.Content.Routing/src/Model/DbRouteStore.cs) | 17 | ||||
-rw-r--r-- | plugins/VNLib.Plugins.Essentials.Content.Routing/src/stores/XmlRouteStore.cs (renamed from plugins/VNLib.Plugins.Essentials.Content.Routing/src/Model/XmlRouteStore.cs) | 5 |
4 files changed, 12 insertions, 15 deletions
diff --git a/plugins/VNLib.Plugins.Essentials.Content.Routing/src/ManagedRouteStore.cs b/plugins/VNLib.Plugins.Essentials.Content.Routing/src/ManagedRouteStore.cs index e2b87a1..8c32e71 100644 --- a/plugins/VNLib.Plugins.Essentials.Content.Routing/src/ManagedRouteStore.cs +++ b/plugins/VNLib.Plugins.Essentials.Content.Routing/src/ManagedRouteStore.cs @@ -1,5 +1,5 @@ /* -* Copyright (c) 2023 Vaughn Nugent +* Copyright (c) 2024 Vaughn Nugent * * Library: VNLib * Package: VNLib.Plugins.Essentials.Content.Routing @@ -29,6 +29,7 @@ using System.Collections.Generic; using VNLib.Plugins.Extensions.Loading; using VNLib.Plugins.Extensions.Loading.Sql; using VNLib.Plugins.Essentials.Content.Routing.Model; +using VNLib.Plugins.Essentials.Content.Routing.stores; namespace VNLib.Plugins.Essentials.Content.Routing { diff --git a/plugins/VNLib.Plugins.Essentials.Content.Routing/src/Router.cs b/plugins/VNLib.Plugins.Essentials.Content.Routing/src/Router.cs index 72f091a..d89ef37 100644 --- a/plugins/VNLib.Plugins.Essentials.Content.Routing/src/Router.cs +++ b/plugins/VNLib.Plugins.Essentials.Content.Routing/src/Router.cs @@ -45,7 +45,7 @@ namespace VNLib.Plugins.Essentials.Content.Routing { private static readonly RouteComparer Comparer = new(); - private readonly IRouteStore Store = plugin.GetOrCreateSingleton<ManagedRouteStore>(); + private readonly ManagedRouteStore Store = plugin.GetOrCreateSingleton<ManagedRouteStore>(); private readonly ILogProvider Logger = plugin.Log; private readonly ConcurrentDictionary<IWebProcessor, Task<ReadOnlyCollection<Route>>> RouteTable = new(); diff --git a/plugins/VNLib.Plugins.Essentials.Content.Routing/src/Model/DbRouteStore.cs b/plugins/VNLib.Plugins.Essentials.Content.Routing/src/stores/DbRouteStore.cs index b7f64e2..634511b 100644 --- a/plugins/VNLib.Plugins.Essentials.Content.Routing/src/Model/DbRouteStore.cs +++ b/plugins/VNLib.Plugins.Essentials.Content.Routing/src/stores/DbRouteStore.cs @@ -1,5 +1,5 @@ /* -* Copyright (c) 2023 Vaughn Nugent +* Copyright (c) 2024 Vaughn Nugent * * Library: VNLib * Package: VNLib.Plugins.Essentials.Content.Routing @@ -35,21 +35,16 @@ using VNLib.Plugins.Extensions.Loading; using VNLib.Plugins.Extensions.Loading.Sql; using VNLib.Plugins.Extensions.Data.Abstractions; using VNLib.Plugins.Extensions.Data.Extensions; +using VNLib.Plugins.Essentials.Content.Routing.Model; -namespace VNLib.Plugins.Essentials.Content.Routing.Model +namespace VNLib.Plugins.Essentials.Content.Routing.stores { - internal sealed class DbRouteStore : DbStore<Route>, IRouteStore + internal sealed class DbRouteStore(PluginBase plugin) : DbStore<Route>, IRouteStore { - private readonly IAsyncLazy<DbContextOptions> Options; + private readonly IAsyncLazy<DbContextOptions> Options = plugin.GetContextOptionsAsync(); public override IDbQueryLookup<Route> QueryTable { get; } = new DbQueries(); - public DbRouteStore(PluginBase plugin) - { - //Load the db context options - Options = plugin.GetContextOptionsAsync(); - } - ///<inheritdoc/> public Task GetAllRoutesAsync(ICollection<Route> routes, CancellationToken cancellation) { @@ -69,7 +64,7 @@ namespace VNLib.Plugins.Essentials.Content.Routing.Model throw new NotSupportedException(); } - private sealed record class DbQueries : IDbQueryLookup<Route> + private sealed class DbQueries : IDbQueryLookup<Route> { public IQueryable<Route> GetCollectionQueryBuilder(IDbContextHandle context, params string[] constraints) { diff --git a/plugins/VNLib.Plugins.Essentials.Content.Routing/src/Model/XmlRouteStore.cs b/plugins/VNLib.Plugins.Essentials.Content.Routing/src/stores/XmlRouteStore.cs index fce193e..52e52e4 100644 --- a/plugins/VNLib.Plugins.Essentials.Content.Routing/src/Model/XmlRouteStore.cs +++ b/plugins/VNLib.Plugins.Essentials.Content.Routing/src/stores/XmlRouteStore.cs @@ -34,8 +34,9 @@ using VNLib.Utils.Memory; using VNLib.Utils.Logging; using VNLib.Utils.Extensions; using VNLib.Plugins.Extensions.Loading; +using VNLib.Plugins.Essentials.Content.Routing.Model; -namespace VNLib.Plugins.Essentials.Content.Routing.Model +namespace VNLib.Plugins.Essentials.Content.Routing.stores { [ConfigurationName("store")] internal sealed class XmlRouteStore : IRouteStore @@ -45,7 +46,7 @@ namespace VNLib.Plugins.Essentials.Content.Routing.Model public XmlRouteStore(PluginBase plugin, IConfigScope config) { //Get the route file path - _routeFile = config["route_file"].GetString() ?? throw new KeyNotFoundException("Missing required key 'route_file' in 'route_store' configuration element"); + _routeFile = config.GetRequiredProperty<string>("route_file"); //Make sure the file exists if (!FileOperations.FileExists(_routeFile)) |