diff options
Diffstat (limited to 'lib/VNLib.Data.Caching.Extensions')
-rw-r--r-- | lib/VNLib.Data.Caching.Extensions/src/Clustering/ICacheDiscoveryErrorHandler.cs | 9 | ||||
-rw-r--r-- | lib/VNLib.Data.Caching.Extensions/src/VNCacheClusterManager.cs | 8 |
2 files changed, 15 insertions, 2 deletions
diff --git a/lib/VNLib.Data.Caching.Extensions/src/Clustering/ICacheDiscoveryErrorHandler.cs b/lib/VNLib.Data.Caching.Extensions/src/Clustering/ICacheDiscoveryErrorHandler.cs index 984ce3d..f27f1fb 100644 --- a/lib/VNLib.Data.Caching.Extensions/src/Clustering/ICacheDiscoveryErrorHandler.cs +++ b/lib/VNLib.Data.Caching.Extensions/src/Clustering/ICacheDiscoveryErrorHandler.cs @@ -1,5 +1,5 @@ /* -* Copyright (c) 2023 Vaughn Nugent +* Copyright (c) 2024 Vaughn Nugent * * Library: VNLib * Package: VNLib.Data.Caching.Extensions @@ -37,5 +37,12 @@ namespace VNLib.Data.Caching.Extensions.Clustering /// <param name="errorNode">The node that the error occured on</param> /// <param name="ex">The exception that caused the invocation</param> void OnDiscoveryError(CacheNodeAdvertisment errorNode, Exception ex); + + /// <summary> + /// Invoked when an error occurs during the discovery process + /// </summary> + /// <param name="errorAddress">The server address that failed to connect</param> + /// <param name="ex">The exception that caused the invocation</param> + void OnDiscoveryError(Uri errorAddress, Exception ex); } } diff --git a/lib/VNLib.Data.Caching.Extensions/src/VNCacheClusterManager.cs b/lib/VNLib.Data.Caching.Extensions/src/VNCacheClusterManager.cs index 4a1a6bd..f68968d 100644 --- a/lib/VNLib.Data.Caching.Extensions/src/VNCacheClusterManager.cs +++ b/lib/VNLib.Data.Caching.Extensions/src/VNCacheClusterManager.cs @@ -93,6 +93,12 @@ namespace VNLib.Data.Caching.Extensions /// <returns>An array of resolved nodes</returns> public async Task<CacheNodeAdvertisment[]> ResolveWellKnownAsync(CancellationToken cancellation) { + //Make sure at least one node defined + if (config?.WellKnownNodes == null || config.WellKnownNodes.Length == 0) + { + throw new ArgumentException("There must be at least one cache node defined in the client configuration"); + } + Task<CacheNodeAdvertisment?>[] initialAdds = new Task<CacheNodeAdvertisment?>[config.WellKnownNodes.Length]; //Discover initial advertisments from well-known addresses @@ -283,7 +289,7 @@ namespace VNLib.Data.Caching.Extensions catch (Exception ex) when (config.ErrorHandler != null) { //Handle the error - config.ErrorHandler.OnDiscoveryError(null!, ex); + config.ErrorHandler.OnDiscoveryError(serverUri, ex); return null; } catch (Exception ex) |