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

Add Metadata collection #1683

Merged
merged 5 commits into from
Oct 26, 2023
Merged

Add Metadata collection #1683

merged 5 commits into from
Oct 26, 2023

Conversation

gjcairo
Copy link
Collaborator

@gjcairo gjcairo commented Oct 24, 2023

Motivation

This PR adds a new Metadata collection for gRPC Core. This collection has the following requirements:

  • is Sendable, Hashable, and a RandomAccessCollection
  • supports string or data values
  • has an iterator for string values for a given key
  • has an iterator for binary values for a given key
  • has subscripts to return iterators for a key
  • is resizable (and can have capacity reserved)
  • has API for adding string values
  • has API for adding binary values which asserts the key is suffixed with “-bin”
  • has API for replacing or adding a value

Modifications

Implemented a new Metadata collection that follows the above requirements.

Result

Metadata collection is available.

@gjcairo gjcairo force-pushed the metadata-collection branch 2 times, most recently from e1fd59e to e8ad94f Compare October 24, 2023 15:04
Copy link
Collaborator

@glbrntt glbrntt left a comment

Choose a reason for hiding this comment

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

This is a great start @gjcairo!

Sources/GRPCCore/Metadata.swift Outdated Show resolved Hide resolved
Sources/GRPCCore/Metadata.swift Outdated Show resolved Hide resolved
Sources/GRPCCore/Metadata.swift Outdated Show resolved Hide resolved
Sources/GRPCCore/Metadata.swift Outdated Show resolved Hide resolved
Sources/GRPCCore/Metadata.swift Outdated Show resolved Hide resolved
Sources/GRPCCore/Metadata.swift Outdated Show resolved Hide resolved
Tests/GRPCCoreTests/Call/Client/ClientRequestTests.swift Outdated Show resolved Hide resolved
Tests/GRPCCoreTests/MetadataTests.swift Outdated Show resolved Hide resolved
Sources/GRPCCore/Metadata.swift Outdated Show resolved Hide resolved
Tests/GRPCTests/GRPCTestCase.swift Show resolved Hide resolved
@gjcairo gjcairo marked this pull request as ready for review October 24, 2023 15:36
@gjcairo gjcairo force-pushed the metadata-collection branch 2 times, most recently from c782124 to a422f61 Compare October 25, 2023 15:14
@gjcairo gjcairo requested a review from glbrntt October 25, 2023 16:34
Copy link
Collaborator

@glbrntt glbrntt left a comment

Choose a reason for hiding this comment

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

This is coming along nicely!

Sources/GRPCCore/Internal/Base64.swift Outdated Show resolved Hide resolved
Sources/GRPCCore/Metadata.swift Outdated Show resolved Hide resolved
Sources/GRPCCore/Metadata.swift Outdated Show resolved Hide resolved
Sources/GRPCCore/Metadata.swift Outdated Show resolved Hide resolved
Sources/GRPCCore/Metadata.swift Outdated Show resolved Hide resolved
Sources/GRPCCore/Metadata.swift Outdated Show resolved Hide resolved
Sources/GRPCCore/Metadata.swift Outdated Show resolved Hide resolved
Sources/GRPCCore/Metadata.swift Show resolved Hide resolved
Sources/GRPCCore/Metadata.swift Show resolved Hide resolved
@glbrntt glbrntt added the semver/none No version change required. label Oct 26, 2023
Copy link
Collaborator

@FranzBusch FranzBusch left a comment

Choose a reason for hiding this comment

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

This looks great overall. Really love the new expressivity for metadata here! Not sure if we should do it in this PR or a follow up but we should have benchmarks for adding/removing/iterating the Metadata. I can already see some methods on the various RandomAccessColllection/Sequence types that are prone to allocate due to missing @inlinable on them.

It might be good to start adding perf benchmarks right away with our new v2 code instead of after the fact. WDYT @glbrntt ?

@glbrntt
Copy link
Collaborator

glbrntt commented Oct 26, 2023

It might be good to start adding perf benchmarks right away with our new v2 code instead of after the fact. WDYT @glbrntt ?

Look at radar ;)

@gjcairo gjcairo requested a review from glbrntt October 26, 2023 13:12
@gjcairo gjcairo force-pushed the metadata-collection branch 3 times, most recently from 354a195 to 1c30ad2 Compare October 26, 2023 14:07
Copy link
Collaborator

@glbrntt glbrntt left a comment

Choose a reason for hiding this comment

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

Couple of nits, otherwise this looks great!

NOTICES.txt Outdated Show resolved Hide resolved
Sources/GRPCCore/Metadata.swift Outdated Show resolved Hide resolved
Sources/GRPCCore/Metadata.swift Outdated Show resolved Hide resolved
Sources/GRPCCore/Metadata.swift Outdated Show resolved Hide resolved
Sources/GRPCCore/Metadata.swift Outdated Show resolved Hide resolved
Sources/GRPCCore/Metadata.swift Show resolved Hide resolved
Sources/GRPCCore/Metadata.swift Outdated Show resolved Hide resolved
Sources/GRPCCore/Metadata.swift Outdated Show resolved Hide resolved
@gjcairo gjcairo requested a review from glbrntt October 26, 2023 16:32
Copy link
Collaborator

@glbrntt glbrntt left a comment

Choose a reason for hiding this comment

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

This is really great, thanks @gjcairo!

@glbrntt glbrntt enabled auto-merge (squash) October 26, 2023 16:35
@glbrntt glbrntt merged commit b58291e into grpc:main Oct 26, 2023
14 checks passed
@gjcairo gjcairo deleted the metadata-collection branch October 30, 2023 08:35
@glbrntt glbrntt added the v2 A change for v2 label Nov 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver/none No version change required. v2 A change for v2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants