Server
The Server is used to build a RPC server which provides RPC Method to one or
more clients. A sample of a simple RPC server is shown here:
import callme
def add(a, b):
return a + b
server = callme.Server(server_id='fooserver',
amqp_host='localhost')
server.register_function(add, 'add')
server.start()
-
class callme.server.Server(server_id, amqp_host='localhost', amqp_user='guest', amqp_password='guest', amqp_vhost='/', amqp_port=5672, ssl=False, threaded=False, durable=False, auto_delete=True)
This Server class is used to provide an RPC server.
Parameters: |
- server_id – id of the server
- amqp_host – the host of where the AMQP Broker is running
- amqp_user – the username for the AMQP Broker
- amqp_password – the password for the AMQP Broker
- amqp_vhost – the virtual host of the AMQP Broker
- amqp_port – the port of the AMQP Broker
- ssl – use SSL connection for the AMQP Broker
- threaded – use of multithreading, if set to true RPC call-execution
will processed parallel (one thread per call) which dramatically
improves performance
- durable – make all exchanges and queues durable
- auto_delete – delete queues after all connections are closed
|
-
is_running
Return whether server is running.
-
register_function(func, name=None)
Registers a function as rpc function so that is accessible from the
proxy.
Parameters: |
- func – the function we want to provide as rpc method
- name – the name with which the function is visible to the clients
|
-
start()
Start the server.
-
stop()
Stop the server.
-
wait()
Wait until server is started.