Closed tjaskula closed 4 years ago
@tjaskula I agree with this. Another way is to use an ActorInstantiator
pattern. Currently in vlingo-java you can use a ActorInstantiator
as a single lambda expression, because it is a @FunctionalInterface
.
() -> new InboundStreamActor(interest, addressType, reader, probeInterval)
You can do this for the actorFor()
that has the overload for an ActorInstantiator
.
@VaughnVernon you mean that you pass () -> new InboundStreamActor(interest, addressType, reader, probeInterval)
inside the actorFor()
right ?
@tjaskula Correct.
Yes, so this should be similar to what I'm going to use on .NET side :)
Oh, ok. The above looked more verbose to me. I see now that I missed this code:
var inboundStream = stage.ActorFor<IInboundStream>(() => new InboundStreamActor(interest, addressType, reader, probeInterval),$"{inboundName}-inbound"))
Today we crate the actor by the following way:
The goal would be to create the actor in the type-safe manner. Why ? Because it easier to be guided by the compiler what parameters to pass in the actor based on the type of actor. Instead we could do the following
For that we would need to leverage creation through expressions like:
For reference on JVM implementation (for impacted files rather than implementation details) : https://github.com/vlingo/vlingo-actors/commit/141f31b926e9534b2306c2768bdd4eefa3e2d519