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 support for RPC status #331

Merged
merged 3 commits into from
Nov 9, 2018
Merged

Add support for RPC status #331

merged 3 commits into from
Nov 9, 2018

Conversation

SebastianThiebaud
Copy link
Contributor

@SebastianThiebaud SebastianThiebaud commented Nov 9, 2018

This closes #258

The new changes provide a way for consumer of grpc-swift to get access to the data stored in the grpc-status-details-bin of metadata.

Here's how to use it in the consumer app:

// Register message types that could be returned in the details field of Status
Google_Protobuf_Any.register(messageType: CustomError.self)

_ = try service.doSomething(request) { response, result in
  result.trailingMetadata?.status?.details // will contain a list of messages that carry the error details
}

@SebastianThiebaud SebastianThiebaud mentioned this pull request Nov 9, 2018
Copy link
Collaborator

@MrMage MrMage left a comment

Choose a reason for hiding this comment

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

Thank you for this change! I am a bit concerned about adding a compiled .pb.swift file to the library source, given that that would require us to also vendor the source .proto file (and add a means of updating that file whenever it or the SwiftProtobuf plugin change).

Also, would it be possible to add tests for the added code as well?

Sources/SwiftGRPC/Core/Metadata.swift Outdated Show resolved Hide resolved
Sources/SwiftGRPC/Core/Metadata.swift Outdated Show resolved Hide resolved
Sources/SwiftGRPC/Core/status.pb.swift Outdated Show resolved Hide resolved
@SebastianThiebaud
Copy link
Contributor Author

@MrMage I added a simple test.

Copy link
Collaborator

@MrMage MrMage left a comment

Choose a reason for hiding this comment

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

Great, thank you for the changes! Looks good to me, will merge once the data accessor is moved, if you don't mind.

Sources/SwiftGRPC/Core/Metadata.swift Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Metadata error
2 participants