We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
In typed actor, if we want to create an actor, we have to use code like this:
CompletionStage<ActorRef<MyType>> future = AskPattern.<SpawnProtocol.Command, ActorRef<MyType>>ask( system, reply -> new SpawnProtocol.Spawn<>( MyType.createBehavior(), "name", Props.empty(), reply), Duration.ofSeconds(3), system.scheduler()) ActorRef<MyType> actorRef = future.toCompletableFuture().join();
for comparison, in classic we have:
Props props = Props.create(MyType.class, ()-> new MyType()).withDispatcher("dispatcher"); ActorRef actorRef = actorSystem.actorOf(props, "name");
Can we wrapper those ask into utility class like this?
public interface SpawnUtility { <T> ActorRef<T> spawn(ActorSystem<SpawnProtocol.Command> spawnableSystem, Behavior<T> behavior, String name, Props props); <T> ActorRef<T> spawn(ActorSystem<SpawnProtocol.Command> spawnableSystem, Behavior<T> behavior, String name); <T> ActorRef<T> spawn(ActorSystem<SpawnProtocol.Command> spawnableSystem, Behavior<T> behavior); <T> CompletionStage<ActorRef<T>> spawnAsync(ActorSystem<SpawnProtocol.Command> spawnableSystem, Behavior<T> behavior, String name, Props props); <T> CompletionStage<ActorRef<T>> spawnAsync(ActorSystem<SpawnProtocol.Command> spawnableSystem, Behavior<T> behavior, String name); <T> CompletionStage<ActorRef<T>> spawnAsync(ActorSystem<SpawnProtocol.Command> spawnableSystem, Behavior<T> behavior); } @Test public void spawnTest(){ ActorSystem<SpawnProtocol.Command> spawnableSystem = null; SpawnUtility utility = null; ActorRef<MyType> actorRef = utility.spawn(spawnableSystem, MyType.createBehavior(), "name"); actorRef.tell(null); }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Motivation
In typed actor, if we want to create an actor, we have to use code like this:
for comparison, in classic we have:
Can we wrapper those ask into utility class like this?
The text was updated successfully, but these errors were encountered: