-
Notifications
You must be signed in to change notification settings - Fork 773
refactor: refactor dfget/core with SupernodeLocator #1325
refactor: refactor dfget/core with SupernodeLocator #1325
Conversation
1bdfa6b
to
1d5d7b6
Compare
1d5d7b6
to
e0e8bb5
Compare
e0e8bb5
to
f7ae939
Compare
Codecov Report
@@ Coverage Diff @@
## master #1325 +/- ##
==========================================
- Coverage 51.32% 50.86% -0.47%
==========================================
Files 126 127 +1
Lines 8327 8346 +19
==========================================
- Hits 4274 4245 -29
- Misses 3709 3755 +46
- Partials 344 346 +2
Continue to review full report at Codecov.
|
c2e4c91
to
68ef2c5
Compare
dfget/core/core.go
Outdated
register = regist.NewSupernodeRegister(cfg, supernodeAPI) | ||
err error | ||
result *regist.RegisterResult | ||
// TODO make it pluggable |
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.
s/TODO/TODO:
dfget/core/core.go
Outdated
if resp != nil && resp.IsSuccess() { | ||
return | ||
node := locator.Get() | ||
if node != nil { |
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.
return quickly when node equals nil
dfget/core/regist/register.go
Outdated
nLen := len(s.cfg.Nodes) | ||
if nLen <= 0 { | ||
return | ||
func (s *supernodeRegister) nodeHostStr(node *locator.Supernode) string { |
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.
use locator.Supernode.String()
function?
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.
the parameter node maybe nil, it will panic
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.
I do not think nodeHostStr
is a function of type supernodeRegister
.
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.
Except this, LGTM.
68ef2c5
to
2787e16
Compare
@starnop PTAL |
66a7c56
to
5d5733b
Compare
dfget/core/regist/register.go
Outdated
@@ -188,28 +179,26 @@ func getTaskPath(taskFileName string) string { | |||
} | |||
|
|||
// NewRegisterResult creates an instance of RegisterResult. | |||
func NewRegisterResult(node string, remainder []string, url string, | |||
func NewRegisterResult(node string, url string, |
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.
node, url, taskID string
dfget/core/regist/register.go
Outdated
nLen := len(s.cfg.Nodes) | ||
if nLen <= 0 { | ||
return | ||
func (s *supernodeRegister) nodeHostStr(node *locator.Supernode) string { |
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.
Except this, LGTM.
97b1ddd
to
25d7443
Compare
@starnop @allencloud done, PTAL |
ceb881e
to
d00c4cb
Compare
Signed-off-by: lowzj <[email protected]>
d00c4cb
to
122ac3c
Compare
LGTM. |
Signed-off-by: lowzj [email protected]
Ⅰ. Describe what this PR did
This pull request uses interface
SupernodeLocator
to refactor thedfget/core
to get supernode list instead of configurations.It also provides a way for users to customized their own
SupernodeLocator
to replace the default implementation, for example:Ⅱ. Does this pull request fix one issue?
fixes: #1293
Ⅲ. Why don't you add test cases (unit test/integration test)? (你真的觉得不需要加测试吗?)
Ⅳ. Describe how to verify it
Ⅴ. Special notes for reviews