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

Expand Cluster.Hosting options #149

Merged

Conversation

Arkatufus
Copy link
Contributor

Part of #142

Changes

  • Expand Cluster.Hosting options
  • Add, expand, and clean up XML-DOCs

@Arkatufus Arkatufus marked this pull request as ready for review December 9, 2022 19:37
@Arkatufus Arkatufus mentioned this pull request Dec 9, 2022
10 tasks
Copy link
Member

@Aaronontheweb Aaronontheweb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to lean more towards ease of use / low friction even if it means not exposing certain settings in Akka.Hosting. Goal of this library is low friction, not completeness.

/// </summary>
public string[] Roles { get; set; }
public Role[]? Roles { get; set; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't like the Role type - adds more friction to the configuration surface in order to expose a feature barely anybody uses. Users can configure this in HOCON if they really want it - please remove it from the UI surface area entirely and go back to using simple strings.

/// If populated, the akka.cluster.seed-nodes that will be used.
/// If populated, the akka.cluster.seed-nodes that will be used.
/// </summary>
public Address[]? SeedNodes { get; set; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So here's a goal worth considering with the ClusterOptions class - should this be parseable from an appsettings.json file / Environment Variable? If so, maybe we should support string here instead and just handle the parsing on the back-end. I'm leaning towards doing that for 1.0.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, let's change this to a string type

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's what we have to do in the current stable version of Akka.Hosting:

var akkaSection = context.Configuration.GetSection("Akka");

// maps to environment variable Akka__ClusterIp
var hostName = akkaSection.GetValue<string>("ClusterIp", "localhost");

// maps to environment variable Akka__ClusterPort
var port = akkaSection.GetValue<int>("ClusterPort", 0);

var seeds = akkaSection.GetValue<string[]>("ClusterSeeds", new[] { "akka.tcp://SqlSharding@localhost:7918" })
    .Select(Address.Parse)
    .ToArray();

It would be amazing if we could just do this instead (and if we decide to go down this route, we should write a unit test that looks like this):

appsettings.json

{
    "Logging": {
        "LogLevel": {
            "Default": "Debug",
            "System": "Information",
            "Microsoft": "Information"
        }
    },
    "Akka": {
        "RemoteOptions":{
            "Hostname": "localhost",
            "Port": 8081,
            "PublicHostname": "localhost",
            "PublicPort": 8081
        },
        "ClusterOptions": {
            "SeedNodes": "akka.tcp://ClusterSystem@localhost:8081",
            "Roles": ["backend"]
        }
    }
}

program.cs

var akkaSection = context.Configuration.GetSection("Akka");
var clusterConfig = akkaSection.Get<ClusterOptions>(); // ideally, this should work

We've not really stated this as an explicit goal for the project before, but in the context of our "pit of success" mission for this library I think it's probably worth doing before we ship 1.0. What do you think?

/// is completed when the singleton actor is terminated. Note that <see cref="PoisonPill"/> is a
/// perfectly fine <see cref="TerminationMessage"/> if you only need to stop the actor.
/// </summary>
public object? TerminationMessage { get; set; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

}

public sealed class ShardOptions
{
/// <summary>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of the ShardOptions changes LGTM

Copy link
Contributor Author

@Arkatufus Arkatufus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self review for the last change request

/// </summary>
public Address[] SeedNodes { get; set; }
public Dictionary<string, int>? MinimumNumberOfMembersPerRole { get; set; }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the line I ment.
Would this be a better compromise to the Role class?
We're not forcing the user to provide any values and still keeps the class as simple as possible.

Copy link
Member

@Aaronontheweb Aaronontheweb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - let's auto-merge this once you resolve your merge conflict

/// </summary>
public Address[] SeedNodes { get; set; }
public Dictionary<string, int>? MinimumNumberOfMembersPerRole { get; set; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I think that's fine

# Conflicts:
#	src/Akka.Cluster.Hosting/AkkaClusterHostingExtensions.cs
@Aaronontheweb Aaronontheweb enabled auto-merge (squash) December 15, 2022 17:21
@Aaronontheweb Aaronontheweb merged commit e18544f into akkadotnet:dev Dec 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants