slime-io / slime

An intelligent ServiceMesh manager based on Istio
https://slime-io.github.io/
Other
425 stars 78 forks source link

meshreg: refactoring source initialisation code to improve extensibility #501

Closed believening closed 5 months ago

believening commented 5 months ago

For the meshregistry module, integrating a new registry source based on the legacy code required not only implementing the integrated logic for the corresponding registry center within the package source, but also duplicating certain formatted code within the package server to complete the registration of the new registry source. This approach not only introduced redundant work but also led to bloated function bodies as the number of registry sources increased. To address this, we have refactored the code responsible for source registration and initialization to enhance extensibility.

For registry sources, we have defined an initializer, RegistrySourceInitializer, to constrain the parameters used and the returns for creating sources, while also providing a function for registry sources to register their RegistrySourceInitializer. Since the parameters for creating sources and their returns are now fixed, we can standardize the process of building and starting various registry sources within the package server. This normalization makes it much easier to integrate new registry sources and significantly simplifies our code. (revolve #488)

For more details about RegistrySourceInitializer, please refer to its comments.

There is still an outstanding issue: different registry sources have their own unique configurations. For newly integrated registry sources, it is still necessary to continuously add new fields to the bootstrap.RegistryArgs structure. We anticipate providing a more user-friendly and extensible configuration interface in the future.