meshreg: refactoring source initialisation code to improve extensibility #501
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 thepackage 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 theirRegistrySourceInitializer
. 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 thepackage 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.