feat: optimize implement of the sync peers #3677
Merged
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.
Description
This pull request includes significant changes to the synchronization of peer information in the
manager
package, specifically focusing on improving the sync process and validation. The most important changes include updating the peer sync logic, adding validation for theBatchSize
parameter, and modifying related tests.Improvements to peer synchronization:
manager/job/sync_peers.go
: Refactored theSyncPeers
interface and related methods to make the sync operation synchronous, ensuring no concurrent sync jobs run simultaneously. The new logic merges sync peer results with the database and handles batch operations more efficiently. [1] [2] [3]Validation enhancements:
manager/config/config.go
: Added validation to ensureBatchSize
is not zero in theValidate
method and updated theSyncPeersConfig
struct to clarify the purpose of theBatchSize
field. [1] [2]Test updates:
manager/config/config_test.go
: Updated tests to include validation for theBatchSize
parameter and ensure proper configuration loading. [1] [2]Configuration updates:
manager/config/constants.go
: Updated the description of the default batch size constant to reflect its dual purpose for syncing peers and database operations.manager/config/testdata/manager.yaml
: Added thebatchSize
parameter to thesyncPeers
configuration in the test data.These changes enhance the robustness and efficiency of the peer synchronization process and ensure proper configuration validation.
Related Issue
Motivation and Context
Screenshots (if appropriate)
Types of changes
Checklist