Skip to content

Guides

The tutorial builds one server and one client. These guides show the rest of what rustorb does, one feature at a time:

  • The POA: policies, object ids, persistent references, POA managers and the POAManagerFactory
  • Any and valuetypes: values of any type, and objects passed by value, shared or not
  • DII and DSI: calling and serving operations without generated code
  • Callback AMI: calls that return at once, with the reply delivered to a handler
  • Transports: TLS, Unix domain sockets, callbacks over the client's connection, addresses behind NAT
  • Timeouts and SyncScope: how long a call waits, and when a oneway call returns
  • Coming from omniORBpy: running omniORBpy applications on rustorb

The examples

The examples are in Python, because they are short and run in one file, and each guide lists the names of the same API in Rust, C++ and Java. C#, C and Ruby follow their mappings; the binding documents (.NET, C, Ruby) list the names. The design documents linked from each guide (in Japanese) have the details.

They share one IDL file:

Demo.idl
module Demo {
  valuetype Point {
    public long x;
    public long y;
  };
  struct Pair {
    Point first;
    Point second;
  };
  exception Overflow { long limit; };
  interface Calc {
    long add(in long a, in long b) raises (Overflow);
    Pair echo_pair(in Pair p);
    any echo_any(in any a);
    oneway void post(in string message);
  };
};

and one servant, calc_impl.py:

calc_impl.py
import Demo, Demo__POA


class CalcImpl(Demo__POA.Calc):
    def add(self, a, b):
        if a + b > 1000:
            raise Demo.Overflow(1000)
        return a + b

    def echo_pair(self, p):
        return p

    def echo_any(self, a):
        return a

    def post(self, message):
        print("posted:", message)

Generate the code (-Wbami adds what callback AMI needs) and run an example with the generated code on the path:

pip install rustorb rustorb-idl
rustorb-idl -bpython -Wbami -C gen Demo.idl
PYTHONPATH=gen:. python3 poa_example.py

Each example starts its server and its client in the same process; the calls go through the ORB just as they would between two processes.