Sunday, April 6, 2014

D has actors now!

Okay so recently it came up in the D newsgroup about akka. Akka is a pretty cool framework (Java/Scala) for multi cpu/host/thread processing of information. It also has a high degree of trust around 'its going to fail so lets handle it'.


But how am I doing it for D exactly? Its a great question. Everything I'm doing is very proof of idea stage, not even a solid concept just yet. Hence not on Github!
I wouldn't have started upon a project like this without a damn good reason. Its a big job working on an actor framework such as this. The reasoning for me is quite simple. I've got planned for Cmsed the ability to do some very similar things with node communication. That being capabilities of nodes, messages, function calling and load balancing. But a lot of this is part of an Actor framework. Just with a lot more security around failing potential. Which is absolutely a great thing in this case!

At this stage there is quite a bit to do. But I have the basics communication between local references. And have them threaded (thanks Vibe for runTask!), but this is only possible if it doesn't return a value. If it returns a value its a blocking task. So whats the point anyway?

The capabilities is quite an exciting concept for me, it allows me to say this node running on this server can do x but not y. So if you try to create an Actor that needs both, enjoy the exception! Not like you shouldn't be handling that anyway..

However one thing that has stood out from the design is that if you have data about an Actor (note this shouldn't really change) it'll be shared. Same goes for methods that are actions.
But other methods like onStart and onStop are not. Why? because they are about the type. They are not interacted with from other sources or at least you hope so.

There is one issue I'm not at all happy with and that is having to check if a constructor is being ran at ctfe. If it is just return. But this is only for ones that use references of Actors. Its okay if you only want to grab a reference and not use it however. It just gives you a nice message saying maybe you made a mistake.

This may need a solution at the compiler/language level.

I probably won't implement everything or enough to give this framework the justice it deserves. But I do believe that if I can get up to the point where I can arbitrarily call methods on another node and raise exceptions as they are created on the original node with it going up to the supervisor, I'll be happy.
Sure its a big ask. But I think its well worth while.

The inclusion into Cmsed won't actually need to be directly done. Logging would be a good idea however. But thats about all that would be required if anything. It would be a simple static if on the Actor framework side. Literally a drop in provider of node communication!

No comments:

Post a Comment