Closed marotili closed 8 years ago
Yes, I think you may be right on this. This was how it was done initially but then I changed it to have actors self register. I don't have a problem with this in principle, the only thing that is fiddly is managing the actor dependencies (between each other). This is another reason why it makes sense to use the 'from' pattern where possible to avoid the circular reference issues between actors.
altough this handling would probably be better from software design perspective, it is not an issue.
IMO registering of actors should be moved outside of the actors. The server actors should be agnostic to the names of themselves and their dependencies to allow better mocking and dynamic behavior (e.g. replacing dependencies at run-time)
Developing and testing using the repl is harder if we use global state. If an actor crashes it will not be unregistered and it has to be manually unregistered.
Blocking calls inside the server behaviors lead to warnings (Uninstrumented methods or call-sites), so calling (whereis actor-name) inside the servers is error prone (Sometimes narjure/core.clj fails to initialize the actors)
A monitor or supervisor actor can be used to register the actors at a later stage. The server actors can be extended to handle a message
For initialization, the actors initialization function can take additional parameters with their dependencies. If circular dependencies exist, the actors can be lazily initialized using the actor-msg.