[feat] protoc-gen-go-triple: Expose unary response headers and trailers in generated Triple client API
Background
Dubbo-Go Triple runtime already has support for unary response metadata through triple_protocol.Response:
resp := triple_protocol.NewResponse(msg)
resp.Header()
resp.Trailer()
The underlying Triple client path can receive response headers and trailers into this response wrapper.
However, the current code generated by protoc-gen-go-triple exposes unary methods like this:
Greet(ctx context.Context, req *GreetRequest, opts ...client.CallOption) (*GreetResponse, error)
The generated method only returns the business response message. The caller cannot access the underlying triple_protocol.Response, so there is no stable way to read unary response headers or trailers from generated clients.
Streaming generated clients already expose this capability:
ResponseHeader() http.Header
ResponseTrailer() http.Header
So response metadata is available for streaming calls, but not for unary calls.
Problem
This makes Triple header/trailer usage incomplete for generated clients:
- Client can send request metadata through Triple metadata APIs.
- Server can set response headers/trailers in the runtime.
- Streaming clients can read response headers/trailers.
- Unary generated clients cannot read response headers/trailers.
This also makes it hard to provide a complete sample for unary header/trailer usage in dubbo-go-samples.
Expected Behavior
Generated unary clients should expose a way to access response headers and trailers.
Possible API directions:
- Add an optional call option that captures response metadata.
- Add a generated unary method variant that returns a response wrapper.
- Support passing a
triple_protocol.Response-like object into generated unary calls.
For example, an API shape similar to one of these would work:
resp, err := cli.Greet(ctx, req, client.WithResponseHeader(header), client.WithResponseTrailer(trailer))
or:
resp, err := cli.GreetWithResponse(ctx, req)
headers := resp.Header()
trailers := resp.Trailer()
msg := resp.Msg
The exact API shape can follow Dubbo-Go's existing generated-code compatibility requirements.
Why This Matters
Issue #2422 asks for a complete Triple header/trailer usage pattern. Without unary response metadata access in generated clients, Dubbo-Go can only document complete response header/trailer readback for streaming calls.
Exposing unary response metadata would make the generated Triple API consistent with the runtime capability and with streaming generated clients.
I would like to work on this , please assign to me
I would like to work on this , please assign to me
sure
close via #3443