-
Notifications
You must be signed in to change notification settings - Fork 773
add seed downloader #1297
add seed downloader #1297
Conversation
Thanks for your contribution. 🍻 @wangforthinker |
fdaf6e7
to
387d807
Compare
Codecov Report
@@ Coverage Diff @@
## master #1297 +/- ##
==========================================
+ Coverage 51.11% 51.12% +0.01%
==========================================
Files 122 124 +2
Lines 8082 8152 +70
==========================================
+ Hits 4131 4168 +37
- Misses 3622 3646 +24
- Partials 329 338 +9
Continue to review full report at Codecov.
|
Signed-off-by: allen.wq <[email protected]>
387d807
to
1da7fba
Compare
LGTM |
|
||
// downloader manage the downloading of seed file. | ||
type downloader interface { | ||
DownloadToWriterAt(ctx context.Context, rangeStruct httputils.RangeStruct, timeout time.Duration, writeOff int64, writerAt io.WriterAt, rateLimit bool) (length int64, err error) |
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 list doesn't contain url
and it's initialized in creating instance of a concrete implementation. Why is it designed this way?
And this method has 2 things to do:
- downloads data from remote server.
- writes data into target writer.
I think that the step 2 may be not the responsibility of downloader interface. Will it be better to remove it from the interface?
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.
- a downloader binds to a seed, so the information of seed will be transferred by creating instance of a concrete implementation. In the other word, we may support other protocol like http/https/oss/hdfs ,so the parameters may not be easy to define.
- in our case, we want to cover the error handler of download. And the data finally should be write ,so we do write in the interface. And some optimization could be make in the interface, such as buffer Write-through which reduces the costs of copying buffer.
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.
LGTM
Ⅰ. Describe what this PR did
Add downloader for seed file. Please see refer dragonflyoss/dragonfly#1284.
Ⅱ. Does this pull request fix one issue?
NONE.
Ⅲ. Why don't you add test cases (unit test/integration test)? (你真的觉得不需要加测试吗?)
Add ut.
Ⅳ. Describe how to verify it
Ⅴ. Special notes for reviews