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

Allow metadata to be mutated on server response types #2120

Merged
merged 1 commit into from
Nov 15, 2024

Conversation

glbrntt
Copy link
Collaborator

@glbrntt glbrntt commented Nov 15, 2024

Motivation:

The server response types have a metadata computed property with only a getter. It's entirely possible to mutate the metadata manually, it's just a bit of a faff. This should be easier.

Modifications:

  • Add a setter to the computed property
  • Migrate server response tests to swift-testing

Result:

  • Easier to use API

Motivation:

The server response types have a metadata computed property with only a
getter. It's entirely possible to mutate the metadata manually, it's
just a bit of a faff. This should be easier.

Modifications:

- Add a setter to the computed property
- Migrate server response tests to swift-testing

Result:

- Easier to use API
Comment on lines +258 to +264
switch self.accepted {
case var .success(contents):
contents.metadata = newValue
self.accepted = .success(contents)
case var .failure(error):
error.metadata = newValue
self.accepted = .failure(error)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just a side note: This might be prone to CoWs and something we might want to make @inlinable or use a consuming switch

@glbrntt glbrntt merged commit dd22b39 into grpc:main Nov 15, 2024
44 of 46 checks passed
@glbrntt glbrntt deleted the v2/mutate-metadata branch November 15, 2024 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🆕 semver/minor Adds new public API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants