Go C#

Amazon ECS Cluster Provider

Amazon ECS provider works very similar to Kubernetes provider. It registers a new member by adding tags to container instance running in ECS cluster. It also polls ECS cluster to receive information about all running instances.

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


static (GrpcNetRemoteConfig, IClusterProvider) ConfigureForAwsEcs(IConfiguration config)
    {
        var awsClient = new AmazonECSClient();
        var containerInstanceName = config["ProtoActor:AwsContainerInstance"];
        var ecsClusterName = config["ProtoActor:AwsEcsClusterName"];

        var clusterProvider = new AmazonEcsProvider
            (
                awsClient, 
                ecsClusterName, 
                containerInstanceName, 
                new AmazonEcsProviderConfig()
            );

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

        var remoteConfig = GrpcNetRemoteConfig
            .BindTo(host, port)
            .WithProtoMessages(YourProtoGrainReflecion.Descriptor);

        return (remoteConfig, clusterProvider);

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

        string? EmptyStringToNull(string? someString) => string.IsNullOrEmpty(someString)
            ? null
            : someString;
    }

Topics
Icon