Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All settings classes like EventStoreClientConnectivitySettings must be records to be equatable out of the box #272

Open
xperiandri opened this issue Nov 7, 2023 · 3 comments

Comments

@xperiandri
Copy link

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 not IEquatable<EventStoreClientConnectivitySettings>

Describe the solution you'd like
Just mark all settings classes as record to bring value semantics and IEquatable<> implementation out of the box

Describe alternatives you've considered
Implement IEqualityComparer for each of the settings class

@alexeyzimarev
Copy link
Member

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.

@xperiandri
Copy link
Author

A connection string may be different while connecting to the same database. And the connection target will not change frrom that

@ylorph
Copy link
Contributor

ylorph commented Nov 8, 2023

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; }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants