dakka 0.0.1
An actor framework, that supports remote method calls.
To use this package, run the following command in your project's root directory:
Manual usage
Put the following dependency into your project's dependences section:
Dakka
Actor based framework in D using Vibe for RPC.
Features:
- Local actor references
- Remote node connections, using given ip/port
- Remote actor calling
- On start/stop/error support
- Capabilities per node (can this node do x? if not which can do to create a reference?)
- Seemless integration of both actor references to actors
- Singleton (controller classes) actor support per node, works with
AllActorRefs
for calling them e.g. sequentially.
Features that should be added:
- Security between nodes
- Better load balancing, currently based off of the lag time of the node and if it has actors on it already
Example:
Definition of an actor:
@DakkaCapability("test")
class MyActorA : Actor {
this(Actor supervisor = null, bool isLocalInstance = true) { super(supervisor, isLocalInstance);}
void test(string s){
logInfo("got a message! %s", s);
}
override void onStart() {
logInfo("Starting actor %s %s", typeText!MyActorA, identifier);
}
override void onStop() {
logInfo("Stopping actor %s %s", typeText!MyActorA, identifier);
}
override void onChildError(Actor actor, string message) {
logInfo("Actor %s %s has child %s that has errored with %s", typeText!MyActorA, identifier, actor.identifier, message);
}
}
Usage of an actor:
The simplist form:
void main() {
registerCapability("test");
registerActor!MyActorA;
MyActorA aref = new ActorRef!MyActorA;
aref.test();
aref.die();
}
But with remote nodes:
server
void main() {
registerCapability("test");
registerActor!MyActorA;
auto sconfig = DakkaServerSettings(11728);
serverStart(sconfig);
runEventLoop();
}
client
void main() {
registerActor!MyActorA;
auto rconfig = DakkaRemoteServer("localhost", ["127.0.0.1"], 11728);
clientConnect(rconfig);
runTask({
sleep(1.seconds);
MyActorA aref = new ActorRef!MyActorA;
aref.test();
aref.die();
});
runEventLoop();
}
Of course you are not forced to use actors on local/remote. This is merely an example. A server can use actors on the client.
As a note, from within an actor, use
actorOf!MyActorB
to get a reference to an actor.
This is a new actor instance of type MyActorB that is a child of the current one. Using the current one as the supervisor.
- Registered by Richard Andrew Cattermole
- 0.0.1 released 10 years ago
- rikkimax/dakka
- MIT
- Copyright © 2014, Richard Andrew Cattermole
- Authors:
- Dependencies:
- vibe-d, cerealed
- Versions:
-
0.0.4 2015-Jan-18 0.0.3 2015-Jan-18 0.0.2 2014-Jul-24 0.0.1 2014-Jul-12 ~master 2015-Jan-19 - Download Stats:
-
-
0 downloads today
-
0 downloads this week
-
0 downloads this month
-
283 downloads total
-
- Score:
- 1.4
- Short URL:
- dakka.dub.pm