Skip to content

Commit

Permalink
perf
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaronontheweb committed Aug 2, 2023
1 parent baf6e07 commit 7c0a7f4
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/contrib/cluster/Akka.Cluster.Sharding/ShardRegion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,15 @@ private void ChangeMembers(IImmutableSet<Member> newMembers)
/// <inheritdoc cref="ActorBase.Receive"/>
protected override bool Receive(object message)
{
// check hotpath first
// if user designed a greedy extractor this may cause problems.
var entityId = _messageExtractor.EntityId(message);
if (!string.IsNullOrEmpty(entityId))
{
DeliverMessage(entityId!, message, Sender);
return true;
}

switch (message)
{
case Terminated t:
Expand Down Expand Up @@ -606,16 +615,9 @@ protected override bool Receive(object message)
DeliverRestartShard(restart, Sender);
return true;
default:
var entityId = _messageExtractor.EntityId(message);
if (entityId is null)
{
_log.Warning("{0}: Message does not have an extractor defined in shard so it was ignored: {1}",
_typeName, message);
return false;
}

DeliverMessage(entityId, message, Sender);
return true;
_log.Warning("{0}: Message does not have an extractor defined in shard so it was ignored: {1}",
_typeName, message);
return false;
}
}

Expand Down

0 comments on commit 7c0a7f4

Please sign in to comment.