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

metadata: add ValueFromIncomingContext to more efficiently retrieve a single value #5596

Merged
merged 6 commits into from
Sep 7, 2022

Conversation

horpto
Copy link
Contributor

@horpto horpto commented Aug 19, 2022

FromIncomingContext creates a copy of md every time.
So even if you need a single header value you will get a value and an overhead for this.
Many interceptors and user code doesn't need all values at a time.

I'd like also to add a helper to just check key existence.

RELEASE NOTES:

  • metadata: add ValueFromIncomingContext to more efficiently retrieve a single value

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Aug 19, 2022

CLA Signed

The committers listed above are authorized under a signed CLA.

FromIncomingContext creates a copy of md every time.
So even if you need a single header value you will get a value and an overhead for this.
Many interceptors and user code doesn't need all values at a time.
@horpto horpto force-pushed the value-from-incoming-context branch from 18ee8a3 to e73bfc2 Compare August 19, 2022 17:17
@zasweq zasweq self-assigned this Aug 27, 2022
Copy link
Contributor

@zasweq zasweq left a comment

Choose a reason for hiding this comment

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

Some comments.

metadata/metadata.go Outdated Show resolved Hide resolved
metadata/metadata.go Outdated Show resolved Hide resolved
metadata/metadata.go Outdated Show resolved Hide resolved
metadata/metadata_test.go Outdated Show resolved Hide resolved
@zasweq zasweq assigned horpto and unassigned zasweq Sep 1, 2022
@horpto horpto requested a review from zasweq September 1, 2022 23:09
@zasweq zasweq assigned zasweq and unassigned horpto Sep 6, 2022
Copy link
Contributor

@zasweq zasweq left a comment

Choose a reason for hiding this comment

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

Few nits, other than LGTM.

metadata/metadata.go Show resolved Hide resolved
metadata/metadata.go Outdated Show resolved Hide resolved
metadata/metadata.go Outdated Show resolved Hide resolved
@zasweq
Copy link
Contributor

zasweq commented Sep 7, 2022

@dfawley for a second reviewer.

@zasweq zasweq added the Type: Feature New features or improvements in behavior label Sep 7, 2022
@zasweq zasweq added this to the 1.50 Release milestone Sep 7, 2022
@zasweq zasweq changed the title Add helper for getting value from incoming context metadata: Add helper for getting value from incoming context Sep 7, 2022
metadata/metadata.go Outdated Show resolved Hide resolved
metadata/metadata.go Outdated Show resolved Hide resolved
metadata/metadata.go Outdated Show resolved Hide resolved
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.

LGTM modulo the two very minor changes. Thanks!

metadata/metadata.go Outdated Show resolved Hide resolved
metadata/metadata.go Show resolved Hide resolved
@dfawley dfawley changed the title metadata: Add helper for getting value from incoming context metadata: add ValueFromIncomingContext to more efficiently retrieve a single value Sep 7, 2022
@dfawley
Copy link
Member

dfawley commented Sep 7, 2022

Thank you for the contribution!

@dfawley dfawley merged commit 60eecd9 into grpc:master Sep 7, 2022
@horpto horpto deleted the value-from-incoming-context branch September 7, 2022 20:22
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Type: Feature New features or improvements in behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants