New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
server/schedule: remove unnecessary interfaces #1679
Conversation
Signed-off-by: disksing <i@disksing.com>
Signed-off-by: disksing <i@disksing.com>
Signed-off-by: disksing <i@disksing.com>
Signed-off-by: disksing <i@disksing.com>
Codecov Report
@@ Coverage Diff @@
## master #1679 +/- ##
==========================================
+ Coverage 76.52% 76.57% +0.04%
==========================================
Files 157 157
Lines 15352 15341 -11
==========================================
- Hits 11748 11747 -1
+ Misses 2587 2583 -4
+ Partials 1017 1011 -6
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passing the cluster
twice when calling a function is really weird. And separating the Cluster
interface into super-interfaces in parameter list seems not a good idea: imagine that a function need all the super-interfaces, its parameter list will become very long.
@Luffbee The basic idea here is to avoid using complex all-in-one Regarding the passing |
I'm not clear about what the "reduce dependency" means, but I think using an all-in-one
So, what a scheduler want is not several interfaces like What's more, using an all-in-one interface here makes the functions signature more uniform, and it is more flexible: if a function is modified and add a dependency, the signature won't need to change. |
reduce dependency means that the Schedulers do need all methods of PS. There is a Go Proverb says The bigger the interface, the weaker the abstraction, you may want to check here for some inspiration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why a cluster should be passed as an argument twice? Does this a mistake?
@@ -116,7 +116,7 @@ func (m *MergeChecker) Check(region *core.RegionInfo) []*operator.Operator { | |||
} | |||
|
|||
log.Debug("try to merge region", zap.Stringer("from", core.RegionToHexMeta(region.GetMeta())), zap.Stringer("to", core.RegionToHexMeta(target.GetMeta()))) | |||
ops, err := operator.CreateMergeRegionOperator("merge-region", m.cluster, region, target, operator.OpMerge) | |||
ops, err := operator.CreateMergeRegionOperator("merge-region", m.cluster, m.cluster, region, target, operator.OpMerge) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is weird to pass m.cluster twice
@shafreeck Will use another approach. Closing. |
What problem does this PR solve?
Cleanup code, remove unnecessary interfaces.
Fix #1664
What is changed and how it works?
cluster.AllocPeer()
, useid.Allocator
interface directlyallocator.Alloc()
toallocator.AllocID
operator.Cluster
, use smaller interfaces instead.Check List
Tests