diff --git a/doc/api/core.protocols.rst b/doc/api/core.protocols.rst new file mode 100644 index 0000000000000000000000000000000000000000..e1537e0704d1ac3c8b545af6b708989f77067291 --- /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 e0d281283e1afea233f09588606acbf8a2a521fc..05613aa3d99c674ec0856b551d4d48cbc6671646 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 bc547135b4178f06b0936d9704e9ad7700d29aa8..2be1e3f549cd82cbd885725d732c53631c8c364a 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 4f19d9772923aba35ede38c569c84af1e524ba2c..f4453cd135189babbe609e7b6594b54c15516280 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 486af56f4f92810cf60b5999ee671e1e2916000c..49ddeea9298d43ada6a972f0b0132913678db1da 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.