Skip to content

Commit

Permalink
Enforce $ name for named system actors (#1650)
Browse files Browse the repository at this point in the history
* Enforce system actor names starts with $
  • Loading branch information
rogeralsing authored Jun 4, 2022
1 parent 2d7f16e commit b7d0669
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/Proto.Actor/Context/SystemContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ public static class SystemContext

public static PID SpawnNamedSystem(this RootContext self, Props props, string name)
{
if (!name.StartsWith("$"))
{
Logger.LogError("SystemContext Failed to spawn system actor {Name}", name);
throw new ArgumentException("System actor names must start with $", nameof(name));
}

try
{
var parent = props.GuardianStrategy is not null
Expand Down
1 change: 0 additions & 1 deletion tests/Proto.Cluster.Tests/PubSubTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,6 @@ async Task Receive(IContext context)
Deliveries.Add(new Delivery(context.ClusterIdentity()!.Identity, msg.Data));
context.Respond(new Response());
break;

case Subscribe msg:
await context.Cluster().Subscribe(msg.Topic, context.ClusterIdentity()!);
context.Respond(new Response());
Expand Down

0 comments on commit b7d0669

Please sign in to comment.