# 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)

  Base registry server

  on_service_added(name, addrinfo)

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

  on_service_removed(name, addrinfo)

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

  cmd_query(host, name)

    implementation of the `query` command

  cmd_list(host, filter_host)

    implementation for the `list` command

  cmd_register(host, names, port)

    implementation of the `register` command

  cmd_unregister(host, port)

    implementation of the `unregister` command

  start()

    Starts the registry server (blocks)

  close()

    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)

  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)

  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)

  Base registry client. Also known as registrar

  discover(name)

    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(filter_host=None)

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

  register(aliases, port)

    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)

    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)

  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)

    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(filter_host=None)

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

  register(aliases, port, interface='')

    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)

    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)

  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)

    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(filter_host=None)

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

  register(aliases, port, interface='')

    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)

    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