From 8c77fe39831e6421d836c29d33b5b4058a3212bb Mon Sep 17 00:00:00 2001 From: Antoine Millet Date: Wed, 28 Sep 2011 10:45:57 +0200 Subject: [PATCH] Updated documentation. --- doc/api/core.protocols.rst | 7 +++++++ doc/api/index.rst | 2 +- doc/fundamentals.rst | 2 +- sjrpc/core/__init__.py | 7 +++++++ sjrpc/core/rpcconnection.py | 26 ++++++++++++++++++++++++++ 5 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 doc/api/core.protocols.rst diff --git a/doc/api/core.protocols.rst b/doc/api/core.protocols.rst new file mode 100644 index 0000000..e1537e0 --- /dev/null +++ b/doc/api/core.protocols.rst @@ -0,0 +1,7 @@ +Protocols +--------- + +.. automodule:: sjrpc.core.protocols + :members: + :inherited-members: + diff --git a/doc/api/index.rst b/doc/api/index.rst index e0d2812..05613aa 100644 --- a/doc/api/index.rst +++ b/doc/api/index.rst @@ -6,7 +6,7 @@ sjRpc API Sub-packages: .. toctree:: - :maxdepth: 2 + :maxdepth: 3 core server diff --git a/doc/fundamentals.rst b/doc/fundamentals.rst index bc54713..2be1e3f 100644 --- a/doc/fundamentals.rst +++ b/doc/fundamentals.rst @@ -8,7 +8,7 @@ in other projects. Features -------- - * **Bidirectional:** remote function can be call by both side of the, + * **Bidirectional:** remote function can be call by both side of the connection, so a client can connect to a server and export functions to it. * **Use Gevent:** the server mode can use Gevent to take profits of asynchronous io, but a threaded mode is also provided. The client mode can diff --git a/sjrpc/core/__init__.py b/sjrpc/core/__init__.py index 4f19d97..f4453cd 100644 --- a/sjrpc/core/__init__.py +++ b/sjrpc/core/__init__.py @@ -13,6 +13,13 @@ This packages export following function/classes: exceptions. * :class:`AsyncWatcher` which allow to make asynchronous calls. +It also contains a sub-package containing protocols: :mod:`core.protocols`. + +.. toctree:: + :hidden: + + api/core.protocols + ''' from sjrpc.core.rpcconnection import * diff --git a/sjrpc/core/rpcconnection.py b/sjrpc/core/rpcconnection.py index 486af56..49ddeea 100644 --- a/sjrpc/core/rpcconnection.py +++ b/sjrpc/core/rpcconnection.py @@ -19,6 +19,32 @@ class RpcConnection(object): ''' This class manage a single peer connection. + You can wrap an existing socket with the default constructor:: + + >>> conn = RpcConnection(mysocket) + + Or create a new socket automatically with from_addr constructor:: + + >>> conn = RpcConnection.from_addr(host, port) + + If you prefer SSL connection, you can use the from_addr_ssl constructor:: + + >>> conn = RpcConnection.from_addr_ssl(host, port) + + By default, an :class:`RpcProtocol` is created on label 0, you can access + to this rpc through the `conn.rpc` shortcut:: + + >>> conn.rpc.call('ping') + + Also, the connection object expose :meth:`call` and :meth:`async_call` + method from default rpc, so you can use it directly on connection:: + + >>> conn.call('ping') # Equivalent to the exemple before + + .. seealso:: + You can read the :ref:`Default rpc, aka Rpc0` section to know more about + the default rpc + :param sock: the socket object of this newly created :class:`RpcConnection` :param \*args,\*\*kwargs: arguments to pass to the default rpc protocol automatically registered on label 0. -- GitLab