aboutsummaryrefslogtreecommitdiff
path: root/Plugins
diff options
context:
space:
mode:
authorLibravatar vman <public@vaughnnugent.com>2022-12-28 14:19:32 -0500
committerLibravatar vman <public@vaughnnugent.com>2022-12-28 14:19:32 -0500
commit9bb5ddd8f19c0ecabd7af4ee58d80c16826bc183 (patch)
tree7f8a3863d18f4673294ab11e427fe0b77fd70abf /Plugins
parent1f2b3530ebeafa162fe4df41e691c33cb2ff0009 (diff)
Cache provider abstractions, reduced deps
Diffstat (limited to 'Plugins')
-rw-r--r--Plugins/CacheBroker/CacheBroker.csproj2
-rw-r--r--Plugins/CacheBroker/Endpoints/BrokerRegistrationEndpoint.cs5
-rw-r--r--Plugins/SessionCacheServer/Endpoints/BrokerHeartBeat.cs6
-rw-r--r--Plugins/SessionCacheServer/Endpoints/ConnectEndpoint.cs14
-rw-r--r--Plugins/SessionCacheServer/ObjectCacheServer.csproj11
-rw-r--r--Plugins/SessionCacheServer/ObjectCacheServerEntry.cs6
-rw-r--r--Plugins/SessionProvider/GlobalCache.cs165
-rw-r--r--Plugins/SessionProvider/SessionProvider.csproj2
8 files changed, 21 insertions, 190 deletions
diff --git a/Plugins/CacheBroker/CacheBroker.csproj b/Plugins/CacheBroker/CacheBroker.csproj
index f4ea139..1d4fdcc 100644
--- a/Plugins/CacheBroker/CacheBroker.csproj
+++ b/Plugins/CacheBroker/CacheBroker.csproj
@@ -6,6 +6,8 @@
<RootNamespace>VNLib.Plugins.Cache.Broker</RootNamespace>
<Authors>Vaughn Nugent</Authors>
<Version>1.0.1.2</Version>
+ <SignAssembly>True</SignAssembly>
+ <AssemblyOriginatorKeyFile>\\vaughnnugent.com\Internal\Folder Redirection\vman\Documents\Programming\Software\StrongNameingKey.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
diff --git a/Plugins/CacheBroker/Endpoints/BrokerRegistrationEndpoint.cs b/Plugins/CacheBroker/Endpoints/BrokerRegistrationEndpoint.cs
index be700d1..7867e97 100644
--- a/Plugins/CacheBroker/Endpoints/BrokerRegistrationEndpoint.cs
+++ b/Plugins/CacheBroker/Endpoints/BrokerRegistrationEndpoint.cs
@@ -33,9 +33,7 @@ using System.Threading;
using System.Net.Sockets;
using System.Threading.Tasks;
using System.Collections.Generic;
-using System.Security.Cryptography;
using System.Text.Json.Serialization;
-using System.Security.Cryptography.X509Certificates;
using RestSharp;
@@ -110,8 +108,7 @@ namespace VNLib.Plugins.Cache.Broker.Endpoints
private async Task<ReadOnlyJsonWebKey> GetClientPublic()
{
- using SecretResult secret = await this.GetPlugin().TryGetSecretAsync("client_public_key") ?? throw new InvalidOperationException("Client public key not found in vault");
- return secret.GetJsonWebKey();
+ return await this.GetPlugin().TryGetSecretAsync("client_public_key").ToJsonWebKey() ?? throw new InvalidOperationException("Client public key not found in vault");
}
private async Task<ReadOnlyJsonWebKey> GetCachePublic()
diff --git a/Plugins/SessionCacheServer/Endpoints/BrokerHeartBeat.cs b/Plugins/SessionCacheServer/Endpoints/BrokerHeartBeat.cs
index 2e380a3..bd1233e 100644
--- a/Plugins/SessionCacheServer/Endpoints/BrokerHeartBeat.cs
+++ b/Plugins/SessionCacheServer/Endpoints/BrokerHeartBeat.cs
@@ -37,7 +37,7 @@ using VNLib.Plugins.Extensions.Loading;
namespace VNLib.Plugins.Essentials.Sessions.Server.Endpoints
{
- internal class BrokerHeartBeat : ResourceEndpointBase
+ internal sealed class BrokerHeartBeat : ResourceEndpointBase
{
public override string Path => "/heartbeat";
@@ -64,9 +64,7 @@ namespace VNLib.Plugins.Essentials.Sessions.Server.Endpoints
private async Task<ReadOnlyJsonWebKey> GetBrokerPubAsync()
{
- using SecretResult brokerPubKey = await Pbase.TryGetSecretAsync("broker_public_key") ?? throw new KeyNotFoundException("Missing required secret : broker_public_key");
-
- return brokerPubKey.GetJsonWebKey();
+ return await Pbase.TryGetSecretAsync("broker_public_key").ToJsonWebKey() ?? throw new KeyNotFoundException("Missing required secret : broker_public_key");
}
protected override async ValueTask<VfReturnType> GetAsync(HttpEntity entity)
diff --git a/Plugins/SessionCacheServer/Endpoints/ConnectEndpoint.cs b/Plugins/SessionCacheServer/Endpoints/ConnectEndpoint.cs
index 77acb13..2fe0994 100644
--- a/Plugins/SessionCacheServer/Endpoints/ConnectEndpoint.cs
+++ b/Plugins/SessionCacheServer/Endpoints/ConnectEndpoint.cs
@@ -47,7 +47,7 @@ using VNLib.Plugins.Essentials.Extensions;
namespace VNLib.Plugins.Essentials.Sessions.Server.Endpoints
{
- class ConnectEndpoint : ResourceEndpointBase
+ internal sealed class ConnectEndpoint : ResourceEndpointBase
{
const int MAX_RECV_BUF_SIZE = 1000 * 1024;
const int MIN_RECV_BUF_SIZE = 8 * 1024;
@@ -194,21 +194,15 @@ namespace VNLib.Plugins.Essentials.Sessions.Server.Endpoints
private async Task<ReadOnlyJsonWebKey> GetClientPubAsync()
{
- using SecretResult brokerPubKey = await Pbase.TryGetSecretAsync("client_public_key") ?? throw new KeyNotFoundException("Missing required secret : client_public_key");
-
- return brokerPubKey.GetJsonWebKey();
+ return await Pbase.TryGetSecretAsync("client_public_key").ToJsonWebKey() ?? throw new KeyNotFoundException("Missing required secret : client_public_key");
}
private async Task<ReadOnlyJsonWebKey> GetCachePubAsync()
{
- using SecretResult cachPublic = await Pbase.TryGetSecretAsync("cache_public_key") ?? throw new KeyNotFoundException("Missing required secret : client_public_key");
-
- return cachPublic.GetJsonWebKey();
+ return await Pbase.TryGetSecretAsync("cache_public_key").ToJsonWebKey() ?? throw new KeyNotFoundException("Missing required secret : client_public_key");
}
private async Task<ReadOnlyJsonWebKey> GetCachePrivateKeyAsync()
{
- using SecretResult cachePrivate = await Pbase.TryGetSecretAsync("cache_private_key") ?? throw new KeyNotFoundException("Missing required secret : client_public_key");
-
- return cachePrivate.GetJsonWebKey();
+ return await Pbase.TryGetSecretAsync("cache_private_key").ToJsonWebKey() ?? throw new KeyNotFoundException("Missing required secret : client_public_key");
}
private async Task ChangeWorkerAsync(CancellationToken cancellation)
diff --git a/Plugins/SessionCacheServer/ObjectCacheServer.csproj b/Plugins/SessionCacheServer/ObjectCacheServer.csproj
index 2cf298d..ff239cc 100644
--- a/Plugins/SessionCacheServer/ObjectCacheServer.csproj
+++ b/Plugins/SessionCacheServer/ObjectCacheServer.csproj
@@ -1,5 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
-
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
@@ -7,7 +6,8 @@
<Version>1.0.1.1</Version>
<RootNamespace>VNLib.Plugins.Essentials.Sessions.Server</RootNamespace>
<Copyright>Copyright © 2022 Vaughn Nugent</Copyright>
-
+ <SignAssembly>True</SignAssembly>
+ <AssemblyOriginatorKeyFile>\\vaughnnugent.com\Internal\Folder Redirection\vman\Documents\Programming\Software\StrongNameingKey.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<!-- Resolve nuget dll files and store them in the output dir -->
@@ -52,7 +52,12 @@
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
- <Exec Command="start xcopy &quot;$(TargetDir)&quot; &quot;$(ProjectDir)/liveplugin/$(TargetName)&quot; /E /Y /R&#xD;&#xA;start xcopy &quot;$(TargetDir)&quot; &quot;\\vaughnnugent.com\Internal\Vaughns Folder\Programming\LiveWebPlugins\SessionServerPlugins/$(TargetName)&quot; /E /Y /R" />
+
+ <Exec Command="erase &quot;\vaughnnugent.com\Internal\Folder Redirection\vman\Documents\Programming\Software\VNLib\Web Plugins/$(TargetName)&quot; /q &gt; nul&#xD;&#xA;start xcopy &quot;$(TargetDir)&quot; &quot;$(ProjectDir)/liveplugin/$(TargetName)&quot; /E /Y /R&#xD;&#xA;start xcopy &quot;$(TargetDir)&quot; &quot;\\vaughnnugent.com\Internal\Folder Redirection\vman\Documents\Programming\Software\VNLib\Web Plugins/$(TargetName)&quot; /E /Y /R" />
+ </Target>
+
+ <Target Name="PostBuild" AfterTargets="PostBuildEvent">
+ <Exec Command="erase &quot;F:\Programming\Web Plugins\DevPlugins\$(TargetName)&quot; /q &gt; nul" />
</Target>
</Project>
diff --git a/Plugins/SessionCacheServer/ObjectCacheServerEntry.cs b/Plugins/SessionCacheServer/ObjectCacheServerEntry.cs
index 20a6268..85a7996 100644
--- a/Plugins/SessionCacheServer/ObjectCacheServerEntry.cs
+++ b/Plugins/SessionCacheServer/ObjectCacheServerEntry.cs
@@ -287,14 +287,12 @@ namespace VNLib.Plugins.Essentials.Sessions.Server
private async Task<ReadOnlyJsonWebKey> GetCachePrivate()
{
- using SecretResult secret = await this.TryGetSecretAsync("cache_private_key") ?? throw new KeyNotFoundException("Failed to load the cache private key");
- return secret.GetJsonWebKey();
+ return await this.TryGetSecretAsync("cache_private_key").ToJsonWebKey() ?? throw new KeyNotFoundException("Failed to load the cache private key");
}
private async Task<ReadOnlyJsonWebKey> GetBrokerPublic()
{
- using SecretResult secret = await this.TryGetSecretAsync("broker_public_key") ?? throw new KeyNotFoundException("Failed to load the broker's public key");
- return secret.GetJsonWebKey();
+ return await this.TryGetSecretAsync("broker_public_key").ToJsonWebKey() ?? throw new KeyNotFoundException("Failed to load the broker's public key");
}
diff --git a/Plugins/SessionProvider/GlobalCache.cs b/Plugins/SessionProvider/GlobalCache.cs
deleted file mode 100644
index 2f64632..0000000
--- a/Plugins/SessionProvider/GlobalCache.cs
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
-* Copyright (c) 2022 Vaughn Nugent
-*
-* Library: VNLib
-* Package: SessionProvider
-* File: GlobalCache.cs
-*
-* GlobalCache.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.Threading;
-using System.Threading.Tasks;
-
-//using VNLib.Data.Caching;
-//using VNLib.Net.Messaging.FBM.Client;
-//using VNLib.Net.Messaging.FBM.Client.Exceptions;
-
-
-namespace VNLib.Plugins.Essentials.Sessions
-{
- /*internal class GlobalCache : IGlobalCacheProvider
- {
- private readonly FBMClient Client;
- private readonly TimeSpan OperationTimeout;
-
- public GlobalCache(FBMClient cacheProvider, TimeSpan cancellation)
- {
- this.Client = cacheProvider;
- this.OperationTimeout = cancellation;
- }
-
- //If the wait handle will block, the client is connected
- bool IGlobalCacheProvider.IsConnected => !Client.ConnectionStatusHandle.WaitOne(0);
-
- async Task IGlobalCacheProvider.DeleteAsync(string key)
- {
- if (OperationTimeout > TimeSpan.Zero && OperationTimeout < TimeSpan.MaxValue)
- {
- CancellationTokenSource cts = new(OperationTimeout);
- try
- {
- //Delete value
- await Client.DeleteObjectAsync(key, cts.Token);
- }
- catch (FBMException fbm)
- {
- //Catch fbm excpetions and wrap them in global cache exception
- throw new GlobalCacheException("Failed to delete cache record, see inner exception", fbm);
- }
- catch (OperationCanceledException)
- {
- throw new TimeoutException("The operation has been cancelled, due to a timeout");
- }
- finally
- {
- cts.Dispose();
- }
- }
- else
- {
- try
- {
- //Delete value
- await Client.DeleteObjectAsync(key);
- }
- catch (FBMException fbm)
- {
- //Catch fbm excpetions and wrap them in global cache exception
- throw new GlobalCacheException("Failed to delete cache record, see inner exception", fbm);
- }
- }
- }
-
- async Task<T> IGlobalCacheProvider.GetAsync<T>(string key)
- {
- if (OperationTimeout > TimeSpan.Zero && OperationTimeout < TimeSpan.MaxValue)
- {
- CancellationTokenSource cts = new(OperationTimeout);
- try
- {
- //Try to get the value
- return await Client.GetObjectAsync<T>(key, cts.Token);
- }
- catch (FBMException fbm)
- {
- //Catch fbm excpetions and wrap them in global cache exception
- throw new GlobalCacheException("Failed to delete cache record, see inner exception", fbm);
- }
- catch (OperationCanceledException)
- {
- throw new TimeoutException("The operation has been cancelled, due to a timeout");
- }
- finally
- {
- cts.Dispose();
- }
- }
- else
- {
- try
- {
- //Try to get the value
- return await Client.GetObjectAsync<T>(key);
- }
- catch (FBMException fbm)
- {
- //Catch fbm excpetions and wrap them in global cache exception
- throw new GlobalCacheException("Failed to delete cache record, see inner exception", fbm);
- }
- }
- }
-
- async Task IGlobalCacheProvider.SetAsync<T>(string key, T value)
- {
- if (OperationTimeout > TimeSpan.Zero && OperationTimeout < TimeSpan.MaxValue)
- {
- CancellationTokenSource cts = new(OperationTimeout);
- try
- {
- await Client.AddOrUpdateObjectAsync(key, null, value, cts.Token);
- }
- catch (FBMException fbm)
- {
- //Catch fbm excpetions and wrap them in global cache exception
- throw new GlobalCacheException("Failed to delete cache record, see inner exception", fbm);
- }
- catch (OperationCanceledException)
- {
- throw new TimeoutException("The operation has been cancelled, due to a timeout");
- }
- finally
- {
- cts.Dispose();
- }
- }
- else
- {
- try
- {
- await Client.AddOrUpdateObjectAsync(key, null, value);
- }
- catch (FBMException fbm)
- {
- //Catch fbm excpetions and wrap them in global cache exception
- throw new GlobalCacheException("Failed to delete cache record, see inner exception", fbm);
- }
- }
- }
- }*/
-}
diff --git a/Plugins/SessionProvider/SessionProvider.csproj b/Plugins/SessionProvider/SessionProvider.csproj
index 98fb5da..6401cb9 100644
--- a/Plugins/SessionProvider/SessionProvider.csproj
+++ b/Plugins/SessionProvider/SessionProvider.csproj
@@ -11,6 +11,8 @@
<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>