-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add BytesMapCarrier #2245
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
Add BytesMapCarrier #2245
Changes from all commits
ca3f3ce
5da702b
617774c
649e029
3733c18
878c1c7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -40,6 +40,32 @@ type TextMapCarrier interface { | |||||||
| // must never be done outside of a new major release. | ||||||||
| } | ||||||||
|
|
||||||||
| // BytesMapCarrier is a Carrier that stores propagated | ||||||||
| // values in a map of bytes. | ||||||||
|
Comment on lines
+43
to
+44
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
| type BytesMapCarrier map[string][]byte | ||||||||
|
|
||||||||
| // Compile time check the BytesMapCarrier implements the TextMapCarrier. | ||||||||
| var _ TextMapCarrier = BytesMapCarrier{} | ||||||||
|
|
||||||||
| // Get returns the value associated with the passed key. | ||||||||
| func (c BytesMapCarrier) Get(key string) string { | ||||||||
| return string(c[key]) | ||||||||
| } | ||||||||
|
|
||||||||
| // Set stores the key-value pair. | ||||||||
| func (c BytesMapCarrier) Set(key string, value string) { | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why input the value as a string and store it as a []byte?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not store the value as a string, vs. storing as a Not blocking, just curiousity. It seems to mean that every call to
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @rakyll would you mind following up, here? |
||||||||
| c[key] = []byte(value) | ||||||||
| } | ||||||||
|
|
||||||||
| // Keys lists the keys stored in this carrier. | ||||||||
| func (c BytesMapCarrier) Keys() []string { | ||||||||
| keys := make([]string, 0, len(c)) | ||||||||
| for k := range c { | ||||||||
| keys = append(keys, k) | ||||||||
| } | ||||||||
| return keys | ||||||||
| } | ||||||||
|
|
||||||||
| // HeaderCarrier adapts http.Header to satisfy the TextMapCarrier interface. | ||||||||
| type HeaderCarrier http.Header | ||||||||
|
|
||||||||
|
|
||||||||
Uh oh!
There was an error while loading. Please reload this page.