Service Discovery

Service Discovery

See the full example here

Using service registration and discovery is very simple. In fact, it only requires two additional lines of code compared to point-to-point calls. Before using this feature, we need to install the relevant registry client. Currently, Dubbo-python only supports Zookeeper, so the following demonstration will use Zookeeper.

Similar to before, we need to clone the Dubbo-python source code and install it. However, in this case, we also need to install the Zookeeper client. The commands are:

  1. git clone https://github.com/apache/dubbo-python.git
  2. cd dubbo-python && pip install .[zookeeper]

After that, simply start Zookeeper and insert the following code into your existing example:

  1. # Configure the Zookeeper registry
  2. registry_config = RegistryConfig.from_url("zookeeper://127.0.0.1:2181")
  3. bootstrap = Dubbo(registry_config=registry_config)
  4. # Create the client
  5. client = bootstrap.create_client(reference_config)
  6. # Create and start the server
  7. bootstrap.create_server(service_config).start()

This enables service registration and discovery within your Dubbo-python project.

Feedback

Was this page helpful?

Yes No

Last modified November 7, 2024: docs: add python sdk manual (#3056) (26c58b388ff)