Description

An actor framework, that supports remote method calls.

Package Information

Version0.0.4 (2015-Jan-18)
Repository https://github.com/rikkimax/dakka
LicenseMIT
CopyrightCopyright © 2014, Richard Andrew Cattermole
AuthorsRichard Andrew Cattermole
Registered byRichard Andrew Cattermole
Sub packages
dakka:base
dakka:vibe-d_wrappers
dakka:test
Dependencies none

Installation

To use this package, put the following dependency into your project's dependencies section:

dub.json
dub.sdl

Readme

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.

Available versions

0.0.4 0.0.3 0.0.2 0.0.1 ~master