Registry

Interpretation of the source code of the registry

Dubbogo abstracts a set of interfaces for the registry as follows:

  1. // Registry Extension - Registry
  2. type Registry interface {
  3. common.Node
  4. // Register is used for service provider calling, register services
  5. // to registry. And it is also used for service consumer calling, register
  6. // services cared about, for dubbo's admin monitoring.
  7. Register(url *common.URL) error
  8. // UnRegister is required to support the contract:
  9. // 1. If it is the persistent stored data of dynamic=false, the
  10. // registration data can not be found, then the IllegalStateException
  11. // is thrown, otherwise it is ignored.
  12. // 2. Unregister according to the full url match.
  13. // url Registration information, is not allowed to be empty, e.g:
  14. // dubbo://10.20.153.10/org.apache.dubbo.foo.BarService?version=1.0.0&application=kylin
  15. UnRegister(url *common.URL) error
  16. // Subscribe is required to support the contract:
  17. // When creating new registry extension, pls select one of the
  18. // following modes.
  19. // Will remove in dubbogo version v1.1.0
  20. // mode1: return Listener with Next function which can return
  21. // subscribe service event from registry
  22. // Deprecated!
  23. // subscribe(event.URL) (Listener, error)
  24. // Will replace mode1 in dubbogo version v1.1.0
  25. // mode2: callback mode, subscribe with notify(notify listener).
  26. Subscribe(*common.URL, NotifyListener) error
  27. // UnSubscribe is required to support the contract:
  28. // 1. If don't subscribe, ignore it directly.
  29. // 2. Unsubscribe by full URL match.
  30. // url Subscription condition, not allowed to be empty, e.g.
  31. // consumer://10.20.153.10/org.apache.dubbo.foo.BarService?version=1.0.0&application=kylin
  32. // listener A listener of the change event, not allowed to be empty
  33. UnSubscribe(*common.URL, NotifyListener) error
  34. }

This interface mainly includes four methods: register, unregister, subscribe, and unsubscribe. As the names suggest, it summarizes the actions for client and server interactions with the registry. For general interface-level service registration scenarios, when the Provider service starts, it abstracts its service interface information into a URL, which contains all the information needed for the client to initiate a call (IP, port, protocol, etc.). The server’s registry component writes this URL to the registry (e.g., Zookeeper). After the client starts, it will subscribe to the required service information through the registry component during the service reference step, and the obtained service information will be written to the client cache in the form of asynchronous event updates. Thus, upon successful service discovery, it can initiate calls to the corresponding service provider based on the retrieved service URL parameters.

Feedback

Was this page helpful?

Yes No

Last modified September 30, 2024: Update & Translate Overview Docs (#3040) (d37ebceaea7)