Open xperiandri opened 8 months ago
Don't you use the connection string? It's the easiest way to configure ESDB client in .NET using ASP.NET Core configuration framework, as well as compare the settings.
A connection string may be different while connecting to the same database. And the connection target will not change frrom that
Why / When do you need to compare and change the connectivity settings ? Most of the time I'm very explicit about those and do not let the code change those on the fly . I.e. something like the following :
{
"ConnectionStrings": {
"default": "esdb+discover://default_cluster_address:2113",
"sandbox": "esdb+discover://sandbox_cluster_address:2113"
}
}
using EventStore.Client;
using Microsoft.Extensions.Configuration;
IConfiguration configuration =new ConfigurationBuilder().AddJsonFile("appsettings.json").Build();
var connections =new Connections(configuration);
Console.WriteLine(connections.Default.ConnectionName);
Console.WriteLine(connections.Default_Follower.ConnectionName);
Console.WriteLine(connections.Sandbox.ConnectionName);
public class Connections {
public Connections(IConfiguration c) {
var settings = EventStoreClientSettings.Create(c.GetConnectionString("default")!);
settings.ConnectionName = "default";
Default = new EventStoreClient(settings);
settings = EventStoreClientSettings.Create(c.GetConnectionString("default")!);
settings.ConnectionName = "default_follower";
settings.ConnectivitySettings.NodePreference = NodePreference.Follower;
Default_Follower = new EventStoreClient(settings);
settings = EventStoreClientSettings.Create(c.GetConnectionString("sandbox")!);
settings.ConnectionName = "sandbox";
Sandbox = new EventStoreClient(settings);
}
public EventStoreClient Default { get; }
public EventStoreClient Default_Follower { get; }
public EventStoreClient Sandbox { get; }
}
Is your feature request related to a problem? Please describe. I have several environments within the same app (default and sandbox). DB connections may vary for each environment. I want to add a health check only if database addresses are different. I want to compare
EventStoreClientConnectivitySettings
but they are notIEquatable<EventStoreClientConnectivitySettings>
Describe the solution you'd like Just mark all settings classes as
record
to bring value semantics andIEquatable<>
implementation out of the boxDescribe alternatives you've considered Implement
IEqualityComparer
for each of the settings class