From 892bbaaa5c1f62631070cc74820f349c4c80f55d Mon Sep 17 00:00:00 2001 From: vnugent Date: Fri, 27 Jan 2023 21:13:16 -0500 Subject: Object cache overhaul and logger updates --- .../CacheBroker/src/Endpoints/BrokerRegistrationEndpoint.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'plugins/CacheBroker/src/Endpoints/BrokerRegistrationEndpoint.cs') diff --git a/plugins/CacheBroker/src/Endpoints/BrokerRegistrationEndpoint.cs b/plugins/CacheBroker/src/Endpoints/BrokerRegistrationEndpoint.cs index c2e0b84..8f983ac 100644 --- a/plugins/CacheBroker/src/Endpoints/BrokerRegistrationEndpoint.cs +++ b/plugins/CacheBroker/src/Endpoints/BrokerRegistrationEndpoint.cs @@ -56,11 +56,12 @@ using VNLib.Net.Rest.Client; namespace VNLib.Plugins.Cache.Broker.Endpoints { [ConfigurationName("broker_endpoint")] - public sealed class BrokerRegistrationEndpoint : ResourceEndpointBase + public sealed class BrokerRegistrationEndpoint : ResourceEndpointBase, IDisposable { const string HEARTBEAT_PATH = "/heartbeat"; - private static readonly RestClientPool ClientPool = new(10,new RestClientOptions() + //Client pool is instance based and may be disposed when the plugin is unloaded + private readonly RestClientPool ClientPool = new(10,new RestClientOptions() { Encoding = Encoding.UTF8, FollowRedirects = false, @@ -69,6 +70,7 @@ namespace VNLib.Plugins.Cache.Broker.Endpoints }, null); + //Matches the json schema set by the FBM caching extensions library private class ActiveServer { [JsonIgnore] @@ -408,5 +410,12 @@ namespace VNLib.Plugins.Cache.Broker.Endpoints _ = ActiveServers.Remove(server.ServerId!); } } + + + void IDisposable.Dispose() + { + //Cleanup client pool when exiting + ClientPool.Dispose(); + } } } -- cgit