Go C#

Consul provider

If Proto.Actor application is not planned to be hosted in a container but e.g. on VMs, bare machine or it is needed to setup clustering on local machine, then this cluster membership provider is the easiest to setup.

Below sample consul provider configuration might be found. More details might be found here.

Provider is available in Proto.Cluster.Consul nuget package.

(GrpcCoreRemoteConfig, IClusterProvider) ConfigureForConsul(IConfiguration config)
        var consulAddress = config["ProtoActor:Consul"];

        var clusterProvider = 
            new ConsulProvider(
                new ConsulProviderConfig(), 
                clientConfiguration: c => c.Address = new Uri(consulAddress)

        var host = EmptyStringToNull(config["ProtoActor:Host"]) ?? "";
        var port = TryParseInt(config["ProtoActor:Port"]) ?? 0;

        vvar remoteConfig = GrpcNetRemoteConfig
            .BindTo(host, port)

        return (remoteConfig, clusterProvider);

        int? TryParseInt(string? intAsString) =>
                ? null
                : int.Parse(intAsString);

        string? EmptyStringToNull(string? someString) => 
                ? null
                : someString;

Example of Consul configuration suitable for local environment might be found here.

How it works?

Consul provider registers a new member in a cluster by using register service call to Consul. After that, in the loop, it sends TTL. It also polls Consul to get update of any member from a cluster. After getting an update, it is propagated by using gossip.