Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Proto.Cluster/Identity/IdentityStorageWorker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ async Task<PidResult> Inner()
//are there any members that can spawn this kind?
//if not, just bail out

var activator = _memberList.GetActivator(clusterIdentity.Kind, sender.Address);
var activator = _memberList.GetActivator(clusterIdentity.Kind, sender.Address, clusterIdentity);

if (activator == null)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Proto.Cluster/Membership/MemberList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ public MemberList(Cluster cluster, bool isClient = false)
internal Task<(bool consensus, ulong topologyHash)> TopologyConsensus(CancellationToken ct) =>
_consensusManager.TopologyConsensus(ct);

internal Member? GetActivator(string kind, string requestSourceAddress) =>
_memberStrategyManager.GetActivator(kind, requestSourceAddress);
internal Member? GetActivator(string kind, string requestSourceAddress, ClusterIdentity identity) =>
_memberStrategyManager.GetActivator(kind, requestSourceAddress, identity);

/// <summary>
/// Used by clustering providers to update the member list.
Expand Down
8 changes: 8 additions & 0 deletions src/Proto.Cluster/Membership/MemberStrategy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ public interface IMemberStrategy
/// <param name="member"></param>
void RemoveMember(Member member);

/// <summary>
/// Assigns a virtual actor to a member.
/// </summary>
/// <param name="senderAddress">Network address of the process that initiated the activation</param>
/// <param name="identity">Identity of the virtual actor to activate</param>
/// <returns>Member to spawn on</returns>
Member? GetActivator(string senderAddress, ClusterIdentity identity) => GetActivator(senderAddress);

/// <summary>
/// Assigns a virtual actor to a member.
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions src/Proto.Cluster/Membership/MemberStrategyManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ internal class MemberStrategyManager

internal MemberStrategyManager(Cluster cluster) => _cluster = cluster;

internal Member? GetActivator(string kind, string requestSourceAddress)
internal Member? GetActivator(string kind, string requestSourceAddress, ClusterIdentity identity)
{
if (_memberStrategyByKind.TryGetValue(kind, out var memberStrategy))
{
return memberStrategy.GetActivator(requestSourceAddress);
return memberStrategy.GetActivator(requestSourceAddress, identity);
}

Logger.DidNotFindActivatorForKind(kind);
Expand Down
4 changes: 2 additions & 2 deletions src/Proto.Cluster/Partition/PartitionIdentityActor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ private Task OnActivationRequest(ActivationRequest msg, IContext context)
}

//Get activator
var activatorAddress = _cluster.MemberList.GetActivator(msg.Kind, context.Sender!.Address)?.Address;
var activatorAddress = _cluster.MemberList.GetActivator(msg.Kind, context.Sender!.Address, msg.ClusterIdentity)?.Address;

if (string.IsNullOrEmpty(activatorAddress))
{
Expand Down Expand Up @@ -687,7 +687,7 @@ TaskCompletionSource<ActivationResponse> setResponse
}

var currentActivatorAddress =
_cluster.MemberList.GetActivator(msg.Kind, context.Sender!.Address)?.Address;
_cluster.MemberList.GetActivator(msg.Kind, context.Sender!.Address, msg.ClusterIdentity)?.Address;
Copy link
Contributor

Choose a reason for hiding this comment

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

My only nitpick is that we now get "kind" twice.
once as a string, and once in the cluster identity.

We always have the full identity in all cases, right?
I´m thinking if we could just. tweak the GetActivator with an overload that just take address and identity (?)

and Obsolete warn on the other one.
I can´t imagine there are many custom member strategies out there in the wild anyway.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good points, cleaning up


if (_myAddress != currentActivatorAddress)
{
Expand Down
Loading