Registry

RPyC Registry Server maintains service information on RPyC services for Service Registry and Discovery patterns. Service Registry and Discovery patterns solve the connectivity problem for communication between services and external consumers. RPyC services will register with the server when auto_register is True.

Service registries such as Avahi and Bonjour are alternatives to the RPyC Registry Server. These alternatives do no support Windows and have more restrictive licensing.

Refer to rpyc/scripts/rpyc_registry.py for more info.

class rpyc.utils.registry.RegistryServer(listenersock, pruning_timeout=None, logger=None, allow_listing=False)[source]

Base registry server

on_service_added(name, addrinfo)[source]

called when a new service joins the registry (but not on keepalives). override this to add custom logic

on_service_removed(name, addrinfo)[source]

called when a service unregisters or is pruned. override this to add custom logic

cmd_query(host, name)[source]

implementation of the query command

cmd_list(host)[source]

implementation for the list command

cmd_register(host, names, port)[source]

implementation of the register command

cmd_unregister(host, port)[source]

implementation of the unregister command

start()[source]

Starts the registry server (blocks)

close()[source]

Closes (terminates) the registry server

class rpyc.utils.registry.UDPRegistryServer(host='0.0.0.0', port=18811, pruning_timeout=None, logger=None, allow_listing=False)[source]

UDP-based registry server. The server listens to UDP broadcasts and answers them. Useful in local networks, were broadcasts are allowed

class rpyc.utils.registry.TCPRegistryServer(host='0.0.0.0', port=18811, pruning_timeout=None, logger=None, reuse_addr=True, allow_listing=False)[source]

TCP-based registry server. The server listens to a certain TCP port and answers requests. Useful when you need to cross routers in the network, since they block UDP broadcasts

class rpyc.utils.registry.RegistryClient(ip, port, timeout, logger=None)[source]

Base registry client. Also known as registrar

discover(name)[source]

Sends a query for the specified service name.

Parameters:name – the service name (or one of its aliases)
Returns:a list of (host, port) tuples
list()[source]

Send a query for the full lists of exposed servers :returns: a list of `` service_name ``

register(aliases, port)[source]

Registers the given service aliases with the given TCP port. This API is intended to be called only by an RPyC server.

Parameters:
  • aliases – the service's aliases
  • port – the listening TCP port of the server
unregister(port)[source]

Unregisters the given RPyC server. This API is intended to be called only by an RPyC server.

Parameters:port – the listening TCP port of the RPyC server to unregister
class rpyc.utils.registry.UDPRegistryClient(ip='255.255.255.255', port=18811, timeout=2, bcast=None, logger=None, ipv6=False)[source]

UDP-based registry clients. By default, it sends UDP broadcasts (requires special user privileges on certain OS’s) and collects the replies. You can also specify the IP address to send to.

Example:

registrar = UDPRegistryClient()
list_of_services = registrar.list()
list_of_servers = registrar.discover("foo")

Note

Consider using rpyc.utils.factory.discover() instead

discover(name)[source]

Sends a query for the specified service name.

Parameters:name – the service name (or one of its aliases)
Returns:a list of (host, port) tuples
list()[source]

Send a query for the full lists of exposed servers :returns: a list of `` service_name ``

register(aliases, port, interface='')[source]

Registers the given service aliases with the given TCP port. This API is intended to be called only by an RPyC server.

Parameters:
  • aliases – the service's aliases
  • port – the listening TCP port of the server
unregister(port)[source]

Unregisters the given RPyC server. This API is intended to be called only by an RPyC server.

Parameters:port – the listening TCP port of the RPyC server to unregister
class rpyc.utils.registry.TCPRegistryClient(ip, port=18811, timeout=2, logger=None)[source]

TCP-based registry client. You must specify the host (registry server) to connect to.

Example:

registrar = TCPRegistryClient("localhost")
list_of_services = registrar.list()
list_of_servers = registrar.discover("foo")

Note

Consider using rpyc.utils.factory.discover() instead

discover(name)[source]

Sends a query for the specified service name.

Parameters:name – the service name (or one of its aliases)
Returns:a list of (host, port) tuples
list()[source]

Send a query for the full lists of exposed servers :returns: a list of `` service_name ``

register(aliases, port, interface='')[source]

Registers the given service aliases with the given TCP port. This API is intended to be called only by an RPyC server.

Parameters:
  • aliases – the service's aliases
  • port – the listening TCP port of the server
unregister(port)[source]

Unregisters the given RPyC server. This API is intended to be called only by an RPyC server.

Parameters:port – the listening TCP port of the RPyC server to unregister