44zerorpc is a flexible RPC implementation based on zeromq and messagepack.
55Service APIs exposed with zerorpc are called "zeroservices".
66
7- zerorpc comes with a convenient script, "zerorpc-client ", allowing to:
7+ zerorpc comes with a convenient script, "zerorpc", allowing to:
88
99* expose Python modules without modifying a single line of code,
1010* call those modules remotely through the command line.
@@ -16,7 +16,7 @@ Create a server with a one-liner
1616Let's see zerorpc in action with a simple example. In a first terminal,
1717we will expose the Python "time" module::
1818
19- $ zerorpc-client --server --bind tcp://*:1234 time
19+ $ zerorpc --server --bind tcp://*:1234 time
2020
2121.. note ::
2222 The bind address uses the zeromq address format. You are not limited
@@ -31,21 +31,21 @@ Call the server from the command-line
3131
3232Now, in another terminal, call the exposed module::
3333
34- $ zerorpc-client --client --connect tcp://*:1234 strftime %Y/%m/%d
34+ $ zerorpc --client --connect tcp://*:1234 strftime %Y/%m/%d
3535 Connecting to "tcp://*:1234"
3636 "2011/03/07"
3737
3838Since the client usecase is the most common one, "--client" is the default
3939parameter, and you can remove it safely::
4040
41- $ zerorpc-client --connect tcp://*:1234 strftime %Y/%m/%d
41+ $ zerorpc --connect tcp://*:1234 strftime %Y/%m/%d
4242 Connecting to "tcp://*:1234"
4343 "2011/03/07"
4444
4545Moreover, since the most common usecase is to *connect * (as opposed to *bind *)
4646you can also omit "--connect"::
4747
48- $ zerorpc-client tcp://*:1234 strftime %Y/%m/%d
48+ $ zerorpc tcp://*:1234 strftime %Y/%m/%d
4949 Connecting to "tcp://*:1234"
5050 "2011/03/07"
5151
@@ -56,7 +56,7 @@ See remote service documentation
5656You can introspect the remote service; it happens automatically if you don't
5757specify the name of the function you want to call::
5858
59- $ zerorpc-client tcp://*:1234
59+ $ zerorpc tcp://*:1234
6060 Connecting to "tcp://*:1234"
6161 tzset tzset(zone)
6262 ctime ctime(seconds) -> string
@@ -78,7 +78,7 @@ Specifying non-string arguments
7878Now, see what happens if we try to call a function expecting a non-string
7979argument::
8080
81- $ zerorpc-client tcp://*:1234 sleep 3
81+ $ zerorpc tcp://*:1234 sleep 3
8282 Connecting to "tcp://*:1234"
8383 Traceback (most recent call last):
8484 [...]
@@ -87,7 +87,7 @@ argument::
8787That's because all command-line arguments are handled as strings. Don't worry,
8888we can specify any kind of argument using JSON encoding::
8989
90- $ zerorpc-client --json tcp://*:1234 sleep 3
90+ $ zerorpc --json tcp://*:1234 sleep 3
9191 Connecting to "tcp://*:1234"
9292 [wait for 3 seconds...]
9393 null
@@ -101,12 +101,12 @@ your server to act as a kind of worker, and connect to a hub or queue which
101101will dispatch requests. You can achieve this by swapping "--bind" and
102102"--connect"::
103103
104- $ zerorpc-client --bind tcp://*:1234 localtime
104+ $ zerorpc --bind tcp://*:1234 localtime
105105
106106We now have "something" wanting to call the "localtime" function, and waiting
107107for a worker to connect to it. Let's start the worker::
108108
109- $ zerorpc-client --server tcp://*:1234 time
109+ $ zerorpc --server tcp://*:1234 time
110110
111111The worker will connect to the listening client and ask him "what should I
112112do?"; the client will send the "localtime" function call; the worker will
@@ -120,10 +120,10 @@ Listening on multiple addresses
120120What if you want to run the same server on multiple addresses? Just repeat
121121the "--bind" option::
122122
123- $ zerorpc-client --server --bind tcp://*:1234 --bind ipc:///tmp/time time
123+ $ zerorpc --server --bind tcp://*:1234 --bind ipc:///tmp/time time
124124
125- You can then connect to it using either "zerorpc-client tcp://*:1234" or
126- "zerorpc-client ipc:///tmp/time".
125+ You can then connect to it using either "zerorpc tcp://*:1234" or
126+ "zerorpc ipc:///tmp/time".
127127
128128Wait, there is more! You can even mix "--bind" and "--connect". That means
129129that your server will wait for requests on a given address, *and * connect
0 commit comments