diff options
author | vnugent <public@vaughnnugent.com> | 2023-01-12 17:47:41 -0500 |
---|---|---|
committer | vnugent <public@vaughnnugent.com> | 2023-01-12 17:47:41 -0500 |
commit | 751e1a107195f0c9c98c866e8267a5a760545982 (patch) | |
tree | 71a775c91bfd9d455b727c72d2fb628c530f64cc /Plugins/SessionProvider | |
parent | 9bb5ddd8f19c0ecabd7af4ee58d80c16826bc183 (diff) |
Large project reorder and consolidation
Diffstat (limited to 'Plugins/SessionProvider')
-rw-r--r-- | Plugins/SessionProvider/LocalizedLogProvider.cs | 72 | ||||
-rw-r--r-- | Plugins/SessionProvider/SessionClientEntryPoint.cs | 148 | ||||
-rw-r--r-- | Plugins/SessionProvider/SessionProvider - Backup (1).csproj | 60 | ||||
-rw-r--r-- | Plugins/SessionProvider/SessionProvider - Backup.csproj | 56 | ||||
-rw-r--r-- | Plugins/SessionProvider/SessionProvider.csproj | 58 |
5 files changed, 0 insertions, 394 deletions
diff --git a/Plugins/SessionProvider/LocalizedLogProvider.cs b/Plugins/SessionProvider/LocalizedLogProvider.cs deleted file mode 100644 index 4062a19..0000000 --- a/Plugins/SessionProvider/LocalizedLogProvider.cs +++ /dev/null @@ -1,72 +0,0 @@ -/* -* Copyright (c) 2022 Vaughn Nugent -* -* Library: VNLib -* Package: SessionProvider -* File: LocalizedLogProvider.cs -* -* LocalizedLogProvider.cs is part of SessionProvider which is part of the larger -* VNLib collection of libraries and utilities. -* -* SessionProvider is free software: you can redistribute it and/or modify -* it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* SessionProvider is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU Affero General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with this program. If not, see https://www.gnu.org/licenses/. -*/ - -using System; - -using VNLib.Utils.Logging; - -namespace VNLib.Plugins.Essentials.Sessions -{ - internal sealed class LocalizedLogProvider : ILogProvider - { - private readonly ILogProvider Log; - private readonly string LogPrefix; - - public LocalizedLogProvider(ILogProvider log, string prefix) - { - Log = log; - LogPrefix = prefix; - } - - public void Flush() - { - Log.Flush(); - } - - public object GetLogProvider() - { - return Log.GetLogProvider(); - } - - public void Write(LogLevel level, string value) - { - Log.Write(level, $"[{LogPrefix}]: {value}"); - } - - public void Write(LogLevel level, Exception exception, string value = "") - { - Log.Write(level, exception, $"[{LogPrefix}]: {value}"); - } - - public void Write(LogLevel level, string value, params object[] args) - { - Log.Write(level, $"[{LogPrefix}]: {value}", args); - } - - public void Write(LogLevel level, string value, params ValueType[] args) - { - Log.Write(level, $"[{LogPrefix}]: {value}", args); - } - } -} diff --git a/Plugins/SessionProvider/SessionClientEntryPoint.cs b/Plugins/SessionProvider/SessionClientEntryPoint.cs deleted file mode 100644 index f429831..0000000 --- a/Plugins/SessionProvider/SessionClientEntryPoint.cs +++ /dev/null @@ -1,148 +0,0 @@ -/* -* Copyright (c) 2022 Vaughn Nugent -* -* Library: VNLib -* Package: SessionProvider -* File: SessionClientEntryPoint.cs -* -* SessionClientEntryPoint.cs is part of SessionProvider which is part of the larger -* VNLib collection of libraries and utilities. -* -* SessionProvider is free software: you can redistribute it and/or modify -* it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* SessionProvider is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU Affero General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with this program. If not, see https://www.gnu.org/licenses/. -*/ - -using System; -using System.IO; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using System.Collections.Generic; - -using VNLib.Net.Http; -using VNLib.Utils.Logging; -using VNLib.Plugins.Extensions.Loading; -using VNLib.Plugins.Essentials.Sessions.Runtime; - -namespace VNLib.Plugins.Essentials.Sessions -{ - /// <summary> - /// The implementation type for dynamic loading of unified session providers - /// </summary> - public sealed class SessionClientEntryPoint : PluginBase, ISessionProvider - { - public override string PluginName => "Essentials.Sessions"; - - - private readonly List<AssemblyLoader<IRuntimeSessionProvider>> ProviderLoaders = new(); - - private IRuntimeSessionProvider[] ProviderArray = Array.Empty<IRuntimeSessionProvider>(); - - - ValueTask<SessionHandle> ISessionProvider.GetSessionAsync(IHttpEvent entity, CancellationToken token) - { - //Loop through providers - for (int i = 0; i < ProviderArray.Length; i++) - { - //Check if provider can process the entity - if (ProviderArray[i].CanProcess(entity)) - { - //Get session - return ProviderArray[i].GetSessionAsync(entity, token); - } - } - - //Return empty session - return new ValueTask<SessionHandle>(SessionHandle.Empty); - } - - protected override void OnLoad() - { - try - { - Log.Verbose("Loading all specified session providers"); - - //Get all provider names - IEnumerable<string> providerAssemblyNames = PluginConfig.GetProperty("provider_assemblies") - .EnumerateArray() - .Where(s => s.GetString() != null) - .Select(s => s.GetString()!); - - - foreach(string asm in providerAssemblyNames) - { - Log.Verbose("Loading {dll} session provider", asm); - - //Attempt to load provider - AssemblyLoader<IRuntimeSessionProvider> prov = this.LoadAssembly<IRuntimeSessionProvider>(asm); - - //Create localized log - LocalizedLogProvider log = new(Log, $"{Path.GetFileName(asm)}"); - - //Try to load the websessions - prov.Resource.Load(this, log); - - //Add provider to list - ProviderLoaders.Add(prov); - } - - if(ProviderLoaders.Count > 0) - { - //Create array for searching for providers - ProviderArray = ProviderLoaders.Select(s => s.Resource).ToArray(); - - Log.Information("Loaded {count} session providers", ProviderArray.Length); - } - else - { - Log.Information("No session providers loaded"); - } - - Log.Information("Plugin loaded"); - } - catch (KeyNotFoundException knf) - { - //Dispose providers - ProviderLoaders.ForEach(s => s.Dispose()); - - Log.Warn("Plugin configuration was missing required variables {var}", knf.Message); - } - catch - { - //Dispose providers - ProviderLoaders.ForEach(s => s.Dispose()); - throw; - } - } - - protected override void OnUnLoad() - { - //Clear array - ProviderArray = Array.Empty<IRuntimeSessionProvider>(); - - //Cleanup assemblies - ProviderLoaders.ForEach(p => p.Dispose()); - ProviderLoaders.Clear(); - - Log.Information("Plugin unloaded"); - } - - protected override void ProcessHostCommand(string cmd) - { - if (!this.IsDebug()) - { - return; - } - } - } -} diff --git a/Plugins/SessionProvider/SessionProvider - Backup (1).csproj b/Plugins/SessionProvider/SessionProvider - Backup (1).csproj deleted file mode 100644 index 7eb7022..0000000 --- a/Plugins/SessionProvider/SessionProvider - Backup (1).csproj +++ /dev/null @@ -1,60 +0,0 @@ -<Project Sdk="Microsoft.NET.Sdk"> - - <PropertyGroup> - <TargetFramework>net6.0</TargetFramework> - <RootNamespace>VNLib.Plugins.Essentials.Sessions</RootNamespace> - <AssemblyName>SessionProvider</AssemblyName> - <PackageId>SessionProvider</PackageId> - <Authors>Vaughn Nugent</Authors> - <Product>SessionProvider</Product> - <Copyright>Copyright © 2022 Vaughn Nugent</Copyright> - <Version>1.0.3.1</Version> - <PackageProjectUrl>www.vaughnnugent.com/resources</PackageProjectUrl> - <Platforms>AnyCPU;x64</Platforms> - </PropertyGroup> - - <ItemGroup> - <PackageReference Include="ErrorProne.NET.CoreAnalyzers" Version="0.1.2"> - <PrivateAssets>all</PrivateAssets> - <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> - </PackageReference> - <PackageReference Include="ErrorProne.NET.Structs" Version="0.1.2"> - <PrivateAssets>all</PrivateAssets> - <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> - </PackageReference> - </ItemGroup> - - <!-- Resolve nuget dll files and store them in the output dir --> - <PropertyGroup> - <EnableDynamicLoading>true</EnableDynamicLoading> - <AssemblyVersion>1.0.2.1</AssemblyVersion> - <FileVersion>1.0.2.1</FileVersion> - <Nullable>enable</Nullable> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'"> - <Deterministic>False</Deterministic> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> - <Deterministic>False</Deterministic> - </PropertyGroup> - <ItemGroup> - <ProjectReference Include="..\..\..\..\VNLib\Utils\src\VNLib.Utils.csproj" /> - <ProjectReference Include="..\..\..\Extensions\VNLib.Plugins.Extensions.Loading\VNLib.Plugins.Extensions.Loading.csproj" /> - <ProjectReference Include="..\..\Libs\VNLib.Plugins.Essentials.Sessions.Runtime\VNLib.Plugins.Essentials.Sessions.Runtime.csproj" /> - </ItemGroup> - - <ItemGroup> - <None Update="SessionProvider.json"> - <CopyToOutputDirectory>Always</CopyToOutputDirectory> - </None> - </ItemGroup> - - <Target Name="PostBuild" AfterTargets="PostBuildEvent"> - <Exec Command="start xcopy "$(TargetDir)" "F:\Programming\Web Plugins\DevPlugins\$(TargetName)" /E /Y /R" /> - </Target> - - <Target Name="PreBuild" BeforeTargets="PreBuildEvent"> - <Exec Command="erase "F:\Programming\Web Plugins\DevPlugins\$(TargetName)" > nul" /> - </Target> - -</Project> diff --git a/Plugins/SessionProvider/SessionProvider - Backup.csproj b/Plugins/SessionProvider/SessionProvider - Backup.csproj deleted file mode 100644 index d20a524..0000000 --- a/Plugins/SessionProvider/SessionProvider - Backup.csproj +++ /dev/null @@ -1,56 +0,0 @@ -<Project Sdk="Microsoft.NET.Sdk"> - - <PropertyGroup> - <TargetFramework>net6.0</TargetFramework> - <RootNamespace>VNLib.Plugins.Essentials.Sessions</RootNamespace> - <AssemblyName>SessionProvider</AssemblyName> - <PackageId>SessionProvider</PackageId> - <Authors>Vaughn Nugent</Authors> - <Product>SessionProvider</Product> - <Copyright>Copyright © 2022 Vaughn Nugent</Copyright> - <Version>1.0.3.1</Version> - <PackageProjectUrl>www.vaughnnugent.com/resources</PackageProjectUrl> - <Platforms>AnyCPU;x64</Platforms> - </PropertyGroup> - - <ItemGroup> - <PackageReference Include="ErrorProne.NET.CoreAnalyzers" Version="0.1.2"> - <PrivateAssets>all</PrivateAssets> - <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> - </PackageReference> - <PackageReference Include="ErrorProne.NET.Structs" Version="0.1.2"> - <PrivateAssets>all</PrivateAssets> - <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> - </PackageReference> - </ItemGroup> - - <!-- Resolve nuget dll files and store them in the output dir --> - <PropertyGroup> - <EnableDynamicLoading>true</EnableDynamicLoading> - <AssemblyVersion>1.0.2.1</AssemblyVersion> - <FileVersion>1.0.2.1</FileVersion> - <Nullable>enable</Nullable> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'"> - <Deterministic>False</Deterministic> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> - <Deterministic>False</Deterministic> - </PropertyGroup> - <ItemGroup> - <ProjectReference Include="..\..\..\..\VNLib\Utils\src\VNLib.Utils.csproj" /> - <ProjectReference Include="..\..\..\Extensions\VNLib.Plugins.Extensions.Loading\VNLib.Plugins.Extensions.Loading.csproj" /> - <ProjectReference Include="..\..\Libs\VNLib.Plugins.Essentials.Sessions.Runtime\VNLib.Plugins.Essentials.Sessions.Runtime.csproj" /> - </ItemGroup> - - <ItemGroup> - <None Update="SessionProvider.json"> - <CopyToOutputDirectory>Always</CopyToOutputDirectory> - </None> - </ItemGroup> - - <Target Name="PostBuild" AfterTargets="PostBuildEvent"> - <Exec Command="start xcopy "$(TargetDir)" "F:\Programming\Web Plugins\DevPlugins\$(TargetName)" /E /Y /R" /> - </Target> - -</Project> diff --git a/Plugins/SessionProvider/SessionProvider.csproj b/Plugins/SessionProvider/SessionProvider.csproj deleted file mode 100644 index 6401cb9..0000000 --- a/Plugins/SessionProvider/SessionProvider.csproj +++ /dev/null @@ -1,58 +0,0 @@ -<Project Sdk="Microsoft.NET.Sdk"> - - <PropertyGroup> - <TargetFramework>net6.0</TargetFramework> - <Nullable>enable</Nullable> - <RootNamespace>VNLib.Plugins.Essentials.Sessions</RootNamespace> - <AssemblyName>SessionProvider</AssemblyName> - <PackageId>SessionProvider</PackageId> - <Authors>Vaughn Nugent</Authors> - <Product>SessionProvider</Product> - <Copyright>Copyright © 2022 Vaughn Nugent</Copyright> - <Version>1.0.3.1</Version> - <PackageProjectUrl>https://www.vaughnnugent.com/resources</PackageProjectUrl> - <SignAssembly>True</SignAssembly> - <AssemblyOriginatorKeyFile>\\vaughnnugent.com\Internal\Folder Redirection\vman\Documents\Programming\Software\StrongNameingKey.snk</AssemblyOriginatorKeyFile> - </PropertyGroup> - - <ItemGroup> - <PackageReference Include="ErrorProne.NET.CoreAnalyzers" Version="0.1.2"> - <PrivateAssets>all</PrivateAssets> - <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> - </PackageReference> - <PackageReference Include="ErrorProne.NET.Structs" Version="0.1.2"> - <PrivateAssets>all</PrivateAssets> - <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> - </PackageReference> - </ItemGroup> - - <!-- Resolve nuget dll files and store them in the output dir --> - <PropertyGroup> - <EnableDynamicLoading>true</EnableDynamicLoading> - <GenerateDocumentationFile>True</GenerateDocumentationFile> - <AnalysisLevel>latest-all</AnalysisLevel> - </PropertyGroup> - - <ItemGroup> - <ProjectReference Include="..\..\..\..\VNLib\Essentials\src\VNLib.Plugins.Essentials.csproj" /> - <ProjectReference Include="..\..\..\..\VNLib\Http\src\VNLib.Net.Http.csproj" /> - <ProjectReference Include="..\..\..\..\VNLib\Utils\src\VNLib.Utils.csproj" /> - <ProjectReference Include="..\..\..\Extensions\VNLib.Plugins.Extensions.Loading\VNLib.Plugins.Extensions.Loading.csproj" /> - <ProjectReference Include="..\..\Libs\VNLib.Plugins.Essentials.Sessions.Runtime\VNLib.Plugins.Essentials.Sessions.Runtime.csproj" /> - </ItemGroup> - - <ItemGroup> - <None Update="SessionProvider.json"> - <CopyToOutputDirectory>Always</CopyToOutputDirectory> - </None> - </ItemGroup> - - <Target Name="PostBuild" AfterTargets="PostBuildEvent"> - <Exec Command="start xcopy "$(TargetDir)" "F:\Programming\Web Plugins\DevPlugins\$(TargetName)" /E /Y /R" /> - </Target> - - <Target Name="PreBuild" BeforeTargets="PreBuildEvent"> - <Exec Command="erase "F:\Programming\Web Plugins\DevPlugins\$(TargetName)" /q > nul" /> - </Target> - -</Project> |