vert-x/mod-lang-scala — pull request #93 by Narigo (2013-11-15 05:46:52+00:00)
Title: Added ScalaBusMod for a nicer interface for eventbus modules

I'd like to delete ModuleBase as it's very java-like and propose this Scala version instead. I've already used something similar in [mod-mysql-postgresql](https://github.com/vert-x/mod-mysql-postgresql/blob/master/src/main/scala/io/vertx/busmod/ScalaBusMod.scala), but I found myself reusing it in almost every single module I've written with Scala. As the Java version provides ModuleBase, this Scala trait gives a lot of syntactic sugar if you use the "almost standard" way of providing an eventbus module.

It relies on the request having an "action" parameter. All other parameters depend on the action (and are thus implemented/handled through the module).

{
"action" : "myaction",
"some-parameter" : 123,
"another-parameter" : true, ...
}

The module then always replies back with either an `Ok` message or an `Error` message. Here is an example for a successful processing:

{
"status" : "ok",
"some-result" : "whatever"
}

And an example for an error while processing:

{
"status" : "error",
"error" : "MY_ERROR_CODE",
"message" : "Some detailed message about the error",
"exception" : "An optional stacktrace of an Exception..."
}

See the tests for a little example on how it is used.

There are some already defined error codes:
* `MODULE_EXCEPTION` - if the module throws an uncaught exception.
* `MISSING_ACTION` - if no action was provided by the sender.
* `INVALID_ACTION` - if the sender sent an action that did not get handled by the module (not in the `receive` method pattern match).