Skip to content
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

Fix doc #1221

Merged
merged 2 commits into from
May 4, 2017
Merged

Fix doc #1221

merged 2 commits into from
May 4, 2017

Conversation

adelez
Copy link
Contributor

@adelez adelez commented May 4, 2017

No description provided.

@adelez adelez requested a review from dfawley May 4, 2017 17:18
@adelez adelez added the Type: Documentation Documentation or examples label May 4, 2017
grpclb.go Outdated
@@ -96,7 +96,7 @@ const (
GRPCLB
)

// AddrMetadataGRPCLB contains the information the name resolution for grpclb should provide. The
// AddrMetadataGRPCLB contains the information the name resolver for grpclb should provide. The
// name resolver used by grpclb balancer is required to provide this type of metadata in
Copy link
Member

Choose a reason for hiding this comment

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

used by the grpclb balancer

@@ -81,12 +81,12 @@ func Pairs(kv ...string) MD {
return md
}

// Len returns the number of items in md.
// Len returns the number of items in MD.
Copy link
Member

Choose a reason for hiding this comment

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

Actually, "md" is correct here (that's the variable name; MD is the type name).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The usage is inconsistent. In line 130 and several other places, MD is used. I'll change all of them to md then.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Another question: do you think using the object name "md" by itself is sufficient or should more readable name be used?

Copy link
Member

Choose a reason for hiding this comment

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

Godocs often refers to parameters or receivers by their name; I think this is fine.

@@ -51,7 +51,7 @@ func DecodeKeyValue(k, v string) (string, string, error) {
// two convenience functions New and Pairs to generate MD.
type MD map[string][]string

// New creates a MD from given key-value map.
// New creates a md from given key-value map.
Copy link
Member

Choose a reason for hiding this comment

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

Here MD is the correct usage. It creates something of the type MD.

"md" should be used where it's referring to a parameter's name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -62,7 +62,7 @@ func New(m map[string]string) MD {
return md
}

// Pairs returns an MD formed by the mapping of key, value ...
// Pairs returns an md formed by the mapping of key, value ...
Copy link
Member

Choose a reason for hiding this comment

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

MD

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -91,9 +91,9 @@ func (md MD) Copy() MD {
return Join(md)
}

// Join joins any number of MDs into a single MD.
// Join joins any number of mds into a single md.
Copy link
Member

Choose a reason for hiding this comment

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

This was probably fine the way it was before. Or:

Join combines mds into a single MD.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

// FromIncomingContext returns the incoming MD in ctx if it exists. The
// returned md should be immutable, writing to it may cause races.
// Modification should be made to the copies of the returned md.
// FromIncomingContext returns the incoming md in ctx if it exists. The
Copy link
Member

Choose a reason for hiding this comment

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

s/md/metadata/ here. It's referring to the concept and not a variable or type.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Also changed the two other mds to MDs.

func FromIncomingContext(ctx context.Context) (md MD, ok bool) {
md, ok = ctx.Value(mdIncomingKey{}).(MD)
return
}

// FromOutgoingContext returns the outgoing MD in ctx if it exists. The
// returned md should be immutable, writing to it may cause races.
// FromOutgoingContext returns the outgoing md in ctx if it exists. The
Copy link
Member

Choose a reason for hiding this comment

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

Same.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Member

@dfawley dfawley left a comment

Choose a reason for hiding this comment

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

One last request, then LGTM. Thanks!

// returned md should be immutable, writing to it may cause races.
// Modification should be made to the copies of the returned md.
// FromIncomingContext returns the incoming metadata in ctx if it exists. The
// returned MD should be immutable. Writing to it may cause races.
Copy link
Member

Choose a reason for hiding this comment

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

should be immutable -> should not be modified.

It is NOT immutable, and this might lead someone to believe that what is returned is a copy of the data and that modifying it is fine but doesn't change the underlying metadata (neither of which is true).

(Also in FromOutgoingContext.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@adelez adelez merged commit 844f573 into grpc:master May 4, 2017
@adelez adelez deleted the doc_fixit branch May 4, 2017 23:42
@menghanl menghanl added the 1.4 label Jun 7, 2017
@lock lock bot locked as resolved and limited conversation to collaborators Jan 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Type: Documentation Documentation or examples
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants