Akka actor invoked with a function delegate - is this bad practice?

153 views Asked by At

I'm building an actor system where a controller actor receives requests and spins up worker actors to perform the various tasks. The worker is invoked with a function delegate that specifies the actual task. So the worker is:

class WorkerActor(workFunc: (OwlChunk=>Unit) => Unit) extends Actor

And the controller spins it up with:

actorRefFactory.actorOf(Props(classOf[WorkerActor], workFuncToBePerformed)

where OwlChunk=>Unit represents a callback for progress reporting to the worker actor. I have all this running, and it works very well in my small testing environment, but I have a feeling I might be violating best-practices for actors. Am I? (For example, when the worker runs its workFunc, is it using bytecode that "belongs to" the controller actor? Is this bad in a distributed system?)

0

There are 0 answers