drmi 0.1.1

D Remote Method Invocation help wraps


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:

D Remote Method Invocation

This package not provide low level transport for messages (RMICall, RMIResponse), but provide high level wraps around your interfaces for packing arguments.

RMICom base interface with one method RMIResponse process(RMICall).

class RMISkeleton(T) : RMICom is server-side wrap, method process must be used in your event loop for dispatch process to real object.

class RMIStub(T) : T is client-side wrap, it's use RMICom for sending messages and get's responses.

Your interface methods must have serializable to vibe.data.json.Json paramters and return value.

Example:

import drmi;

struct Point { double x, y, z; }

interface Test
{
    int foo(string abc, int xyz);
    string foo(string str);
    string bar(double val);
    double len(Point pnt);
    string state() @property;
    void state(string s) @property;
}

class Realization : Test
{
    string _state;
override:
    string foo(string str) { return "<" ~ str ~ ">"; }
    int foo(string abc, int xyz) { return cast(int)(abc.length * xyz); }
    string bar(double val) { return val > 3.14 ? "big" : "small"; }
    double len(Point pnt)
    {
        import std.math;
        return sqrt(pnt.x^^2 + pnt.y^^2 + pnt.z^^2);
    }
    string state() @property { return _state; }
    void state(string s) @property { _state = s; }
}

void main()
{
    auto rea = new Realization;
    auto ske = new RMISkeleton!Test(rea);
    // use `ske` in low level transaction mechanism
    // for `cli` write RMICom low lovel transaction mechanism realization
    auto cli = new RMIStub!Test(ske);

    assert(rea.foo("hello", 123) == cli.foo("hello", 123));
    assert(rea.bar(2.71) == cli.bar(2.71));
    assert(rea.bar(3.1415) == cli.bar(3.1415));
    assert(rea.foo("okda") == cli.foo("okda"));
    assert(rea.len(Point(1,2,3)) == cli.len(Point(1,2,3)));

    static str = "ololo";
    cli.state = str;
    assert(rea.state == str);
    assert(cli.state == str);
}
Authors:
  • Oleg Butko (deviator)
Dependencies:
vibe-d:data
Versions:
0.15.0 2019-Sep-09
0.14.0 2018-Dec-03
0.13.0 2018-May-03
0.12.1 2018-Feb-26
0.12.0 2017-Nov-14
Show all 36 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 0 downloads this month

  • 5728 downloads total

Score:
1.0
Short URL:
drmi.dub.pm