Skip to content

Add RPC framework

Samuel Debionne requested to merge add-rpc-framework into develop

The RPC framework is a generic client-server architecture based on:

  • Boost.Serialization for the marshaling of commands / results / events
  • Boost.MPI for the communication
  • Boost.Hana for instrospection and generative programming

Interface

Given an interface definition like:

struct service
{
	std::string name() const;
	int exit();
};


struct calculator : service
{
	double add(double v);
	double add2(double v, double v2);
	double sub(double v);
	double mult(double v);
	double div(double v);

	double result() const;

	void reset();
};

BOOST_HANA_ADAPT_STRUCT(calculator, name, exit, add, add2, sub, mult, div, result, reset);

Client

A client can be instantiated with:

#include <lima/rpc/client.hpp>

...

int main(int argc, char* argv[])
{
    mpi::environment env;
    mpi::communicator world;

    rpc::client<calculator> client(world);
    auto name = client.name();
    auto val = client.add(5.0);
    client.reset();
    return client.exit();
}

Server

A server can be instantiated with:

#include <lima/rpc/client.hpp>

...

int main(int argc, char* argv[])
{
    mpi::environment env;
    mpi::communicator world;

    // Create and run server
    rpc::server<calculator, calculator_impl> server(world);
    server.listen();
}

A couple of things need to be added for the implementation to be feature complete:

  • Serialization of exceptions
  • Events
  • Macro to generate the mirror_interface helper or find a better way to do this
  • Asynch communication and std::future like interface

The tests need a little more work as well:

  • I need a little patch on Boost.Hana to make that work.
  • I don't know how to run MPI distributed tests yet
Edited by Samuel Debionne

Merge request reports