berryMQ logo

JSON-RPC Protocol

berryMQ uses JSON-RPC as a communication protocol. berrymq.connect.ExportedFunctions class implements JSON-RPC interface.

Terms

addr
This is a tuple of URL and port number.
ttl
Time to Live. Unit is “second”. If nodes don’t communicate longer than this term, line will be disconnected.
token
This identifies connections. In python this is generated by str(uuid.uuid1()).
client
This is a node which calls “connection” procedures.
server
This is a node which is called “connection” procedures from client.

JSON-RPC functions

class berrymq.connect.ExportedFunctions
interconnect(addr, token, ttl)

Connect to other node equality. This is inter-process style01.

You should generate token at client side and pass to server. Once you call this function, this node will callback to addr.

Returns:token
Return type:str
connect_oneway(ttl)

Connect to other node. Target node won’t call back to client. This is inter-process style02.

Returns:token
Return type:str
connect_via_queue(identifier, ttl)

Connect to other node with queue. This is inter-process style03.

Parameter:identifier (str) – receive filter. see Identifier
Returns:token
Return type:str
send_message(token, identifier, args, kwargs)

It’s key function for inter-process communication.

Parameters:
  • token (str) – return value of connection methods
  • identifier (str) – message identifier
  • args (list) – message args
  • kwargs (dict) – message keyword args
Returns:

status code

Return type:

“ok” or “invalid token” or “timeout”

get(token, block, timeout):

Get message from queue. This function is available if you connect by connect_via_queue().

Returns:message object or error code
Return type:{id, args, kwargs} or “invalid token” or “timeout”
get_nowait(token)
Returns:message object or error code
Return type:{id, args, kwargs} or “invalid token” or “timeout”
close_connection(token)

close session.

Parameter:token (str) – return value of connection methods

Table Of Contents

Previous topic

Special Messages

Next topic

Features Chart

This Page