Skip to content
This repository was archived by the owner on Dec 20, 2024. It is now read-only.

Feat/add implementation for dfget interface#1352

Merged
lowzj merged 1 commit into
dragonflyoss:masterfrom
antsystem:feat/add-implementation-for-dfget-interface
May 25, 2020
Merged

Feat/add implementation for dfget interface#1352
lowzj merged 1 commit into
dragonflyoss:masterfrom
antsystem:feat/add-implementation-for-dfget-interface

Conversation

@wangforthinker

Copy link
Copy Markdown
Contributor

Ⅰ. Describe what this PR did

Add implementation of http protocol of dfget interface.

Ⅱ. 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

@wangforthinker wangforthinker force-pushed the feat/add-implementation-for-dfget-interface branch 2 times, most recently from ae0cf29 to ed738a8 Compare May 19, 2020 09:44
@codecov-commenter

codecov-commenter commented May 19, 2020

Copy link
Copy Markdown

Codecov Report

Merging #1352 into master will decrease coverage by 0.13%.
The diff coverage is 43.16%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1352      +/-   ##
==========================================
- Coverage   51.34%   51.21%   -0.14%     
==========================================
  Files         130      133       +3     
  Lines        8578     8717     +139     
==========================================
+ Hits         4404     4464      +60     
- Misses       3806     3875      +69     
- Partials      368      378      +10     
Impacted Files Coverage Δ
pkg/protocol/http/http.go 30.66% <30.66%> (ø)
pkg/protocol/http/resource.go 49.05% <49.05%> (ø)
pkg/protocol/http/md.go 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 54f0a67...3cd96a0. Read the comment docs.

Comment thread pkg/protocol/http/http.go Outdated

const (
// http protocol name
ProtocolName = "http"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it contain http and https?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add htttps support.

Comment thread pkg/protocol/http/http.go
}

// Client is an implementation of protocol.Client for http protocol.
type Client struct {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

create an anonymous instant to check whether the struct implements the interface, like:

var _ protocol.Client = &Client{}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add it.

Comment thread pkg/protocol/http/http.go Outdated
type ClientBuilder struct{}

func (cb *ClientBuilder) NewProtocolClient(clientOpt interface{}) (protocol.Client, error) {
opt, ok := clientOpt.(*ClientOpt)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it allow to nil clientOpt?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allow nil clientOpt.

Comment thread pkg/protocol/http/http.go Outdated
}

if hd == nil {
hd = NewHTTPMetaData().(*Headers)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why must create it? I think, it can be nil.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allow it.

Comment thread pkg/protocol/http/resource.go Outdated

defer res.Body.Close()
lenStr := res.Header.Get(config.StrContentLength)
if len(lenStr) == 0 {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use lenStr == "" to instead of this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@wangforthinker wangforthinker force-pushed the feat/add-implementation-for-dfget-interface branch 2 times, most recently from b35a1d2 to 7fc0988 Compare May 20, 2020 02:47
Comment thread pkg/protocol/http/http.go Outdated

// ClientOpt is the argument of NewProtocolClient.
type ClientOpt struct {
transport http.RoundTripper

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change to map[string]interface, tell the user the keys which could be set.

@wangforthinker wangforthinker force-pushed the feat/add-implementation-for-dfget-interface branch from 7fc0988 to 2086f69 Compare May 25, 2020 06:23
Signed-off-by: allen.wq <allen.wq@alipay.com>
@wangforthinker wangforthinker force-pushed the feat/add-implementation-for-dfget-interface branch from 2086f69 to 3cd96a0 Compare May 25, 2020 06:27

@lowzj lowzj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lowzj lowzj merged commit 3945cdb into dragonflyoss:master May 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants