From d4f10bc851dce355415bd7c2cdc8ab2a0a365b4d Mon Sep 17 00:00:00 2001 From: Martijn Laarman Date: Mon, 10 Jul 2023 12:01:26 +0200 Subject: [PATCH] Ensure IEphemeralCluster extends ICluster Which is a new base interface also for ICluster This makes `GetOrAddClient` a lot more capable of determining how to best build the client --- .../IEphemeralCluster.cs | 2 +- .../ClusterBase.cs | 29 ++++++++++++++----- .../XunitClusterExtensions.cs | 3 +- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/Elastic.Elasticsearch.Ephemeral/IEphemeralCluster.cs b/src/Elastic.Elasticsearch.Ephemeral/IEphemeralCluster.cs index a383389..d0185a4 100644 --- a/src/Elastic.Elasticsearch.Ephemeral/IEphemeralCluster.cs +++ b/src/Elastic.Elasticsearch.Ephemeral/IEphemeralCluster.cs @@ -8,7 +8,7 @@ namespace Elastic.Elasticsearch.Ephemeral { - public interface IEphemeralCluster + public interface IEphemeralCluster : ICluster { ICollection NodesUris(string hostName = null); string GetCacheFolderName(); diff --git a/src/Elastic.Elasticsearch.Managed/ClusterBase.cs b/src/Elastic.Elasticsearch.Managed/ClusterBase.cs index 8f8f28c..110bf31 100644 --- a/src/Elastic.Elasticsearch.Managed/ClusterBase.cs +++ b/src/Elastic.Elasticsearch.Managed/ClusterBase.cs @@ -17,14 +17,32 @@ namespace Elastic.Elasticsearch.Managed { - public interface ICluster : IDisposable - where TConfiguration : IClusterConfiguration + public interface ICluster { + /// + /// Whether known proxies were detected as running during startup + /// + DetectedProxySoftware DetectedProxy { get; } + + /// A friendly name for this cluster, derived from the implementation name string ClusterMoniker { get; } - TConfiguration ClusterConfiguration { get; } + + /// INodeFileSystem FileSystem { get; } + + /// Indicating if this cluster was started correctly bool Started { get; } + + /// + /// The collection of 's that make up the cluster + /// ReadOnlyCollection Nodes { get; } + } + + public interface ICluster : ICluster,IDisposable + where TConfiguration : IClusterConfiguration + { + TConfiguration ClusterConfiguration { get; } IConsoleLineHandler Writer { get; } IDisposable Start(); @@ -32,11 +50,6 @@ public interface ICluster : IDisposable IDisposable Start(TimeSpan waitForStarted); IDisposable Start(IConsoleLineHandler writer, TimeSpan waitForStarted); - - /// - /// Whether known proxies were detected as running during startup - /// - DetectedProxySoftware DetectedProxy { get; } } diff --git a/src/Elastic.Elasticsearch.Xunit/XunitClusterExtensions.cs b/src/Elastic.Elasticsearch.Xunit/XunitClusterExtensions.cs index a00a1e8..5472d20 100644 --- a/src/Elastic.Elasticsearch.Xunit/XunitClusterExtensions.cs +++ b/src/Elastic.Elasticsearch.Xunit/XunitClusterExtensions.cs @@ -13,8 +13,7 @@ namespace Elastic.Elasticsearch.Xunit /// public static class XunitClusterExtensions { - private static readonly ConcurrentDictionary Clients = - new ConcurrentDictionary(); + private static readonly ConcurrentDictionary Clients = new(); /// /// Gets a client for the cluster if one exists, or creates a new client if one doesn't.