Open maznikoff opened 1 year ago
Feeding in extension data (or decoding options) is not currently possible; we should add support for this though.
For the client, you can work around it by providing a wrapper type for your messages:
struct ProtoWrapper<ProtoMessage: Message>: GRPCPayload {
var message: ProtoMessage
init(_ message: ProtoMessage) {
self.message = message
}
init(serializedByteBuffer buffer: inout ByteBuffer) throws {
let extensions = ...
self.message = try .init(serializedData: Data(buffer: buffer), extensions: extensions)
}
func serialize(into buffer: inout ByteBuffer) throws {
buffer.writeData(try self.message.serializedData())
}
}
extension Message {
var wrapped: ProtoWrapper<Self> { return .init(self) }
}
And then manually making calls with your client:
let client = GRPCAnyServiceClient(channel: ...)
let call = client.makeUnaryCall(path: "/echo.Echo/Get", request: request.wrapped, responseType: ProtoMessage<Response>.self)
Describe the bug
Having a service and messages like these:
Golang server sends a response and sets MyCustomData as extension of MyData. iOS client receives the MyResponse message, but getting nil for the extension of MyData.
Both server and client are able to set & get extensions of the messages created locally.
GRPC Serialization code shows a sign that extensions are just ignored, because it just passes serialized data to the Message init and doesn't pass the extensions:
swift-protobuf Message sources:
protoc-gen-grpc-swift version: latest