geod24.LocalRest

Provides utilities to moch an async REST node on the network

Using vibe.web.rest allow to cleanly separate business code from network code, as implementing an interface is all that's needed to create a server.

However, in order for tests to simulate an asynchronous system accurately, multiple nodes need to be able to run concurrently.

There are two common solutions to this, to use either fibers or threads. Fibers have the advantage of being simpler to implement and predictable. Threads have the advantage of more accurately describing an asynchronous system and thus have the ability to uncover more issues. Fibers also need to cooperate (by yielding), which means the code must be more cautiously instrumented to allow it to be used for tests, while Threads will just work.

The later reason is why this module went with Thread. When spawning a node, a thread is spawned, a node is instantiated with the provided arguments, and an event loop waits for messages sent to the Tid. Messages consist of the sender's Tid, the mangled name of the function to call (to support overloading) and the arguments, serialized as a JSON string.

While this module's main motivation was to test REST nodes, the only dependency to Vibe.d is actually to it's JSON module, as Vibe.d is the only available JSON module known to the author to provide an interface to deserialize composite types.

Members

Classes

RemoteAPI
class RemoteAPI(API, Implementation : API)

Simple wrapper to deal with tuples Vibe.d might emit a pragma(msg) when T.length == 0

Meta

Authors

Mathias 'Geod24' Lang

License

MIT (See LICENSE.txt)