protobuf-net / protobuf-net.Grpc

GRPC bindings for protobuf-net and grpc-dotnet
Other
857 stars 109 forks source link

Design thoughts: header/trailer advanced usage #285

Open mgravell opened 1 year ago

mgravell commented 1 year ago

Note ties into #284

Consider:

SomeType Method1(SomeType arg, [Header] string x, ...)
SomeType Method2(SomeType arg, [Header] out string x, ...)
SomeType Method3(SomeType arg, [Header] ref string x, ...)
SomeType Method1(SomeType arg, [Trailer] string x, ...)
SomeType Method2(SomeType arg, [Trailer] out string x, ...)
SomeType Method3(SomeType arg, [Trailer] ref string x, ...)

Thoughts?

menaheme commented 1 year ago

Does this open up the way to have more than one input parameter (excluding context)?

mgravell commented 1 year ago

Yes, although I also want to allow full body binding as protobuf implied models. But I have definitely missed an important category above - binary headers that are serialized object payloads. I'm conflicted as to whether to add this one, as header sizes are bounded. Open to thoughts, though... i.e.

..., [Header] SomeType arg, ...
..., [Header] in SomeType arg, ...
..., [Header] ref SomeType arg, ...
..., [Header] out SomeType arg, ...

(and [Trailer])

which should only work if SomeType is recognized by the configured marshaller

menaheme commented 1 year ago

Hmm, the difference between method parameter types and header types, is that the former are contracted in the interface signature , the latter are not documented anywhere, which is risky

mgravell commented 1 year ago

Partly. Also no streaming for headers. And headers have more limited sizes. And the marshaller API is different (although I've suggested some improvements for that over on gRPC.Core)

menaheme commented 1 year ago

How does one communicate to comsumer, the header type expected at the server?

mgravell commented 1 year ago

Well, in code-first land: like the above :)

In contract-first: "you tell them"