Skip to content

Commit

Permalink
Some adjusts
Browse files Browse the repository at this point in the history
  • Loading branch information
Adriano Santos committed Oct 18, 2023
1 parent 6ccd74f commit 477cfe3
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions lib/src/stateful_named_actor_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,17 @@ class StatefulNamedActorHandler implements ActorHandler {
}
}

@override
String getRegisteredName() {
String? name = _statefulNamedActorAnnotationInstance?.name;

if (name == null || name.isEmpty) {
return MirrorSystem.getName(_mirror!.simpleName);
}

return name;
}

@override
spawn_protocol.ActorInvocationResponse handleInvoke(
spawn_protocol.ActorInvocation invocation) {
Expand All @@ -54,25 +65,18 @@ class StatefulNamedActorHandler implements ActorHandler {
Optional.of(ReflectHelper.createInstance(actorEntityType!));

if (actorInstance.isEmpty) {
throw StateError("Actor not found Or error during instance creation");
throw StateError(
"Actor ${invocation.actor.name} not found or error during instance creation");
}

spawn_protocol.ActorInvocationResponse response =
spawn_protocol.ActorInvocationResponse.create()
..actorName = invocation.actor.name
..actorSystem = invocation.actor.system
..updatedContext = spawn_protocol.Context.create();
return response;
}

@override
String getRegisteredName() {
String? name = _statefulNamedActorAnnotationInstance?.name;

if (name == null || name.isEmpty) {
return MirrorSystem.getName(_mirror!.simpleName);
if (actions.containsKey(invocation.actionName)) {
return spawn_protocol.ActorInvocationResponse.create()
..actorName = invocation.actor.name
..actorSystem = invocation.actor.system
..updatedContext = spawn_protocol.Context.create();
}

return name;
throw ArgumentError(
"Action ${invocation.actionName} not found for Actor ${invocation.actor.name}.");
}
}

0 comments on commit 477cfe3

Please sign in to comment.