dubbo-go icon indicating copy to clipboard operation
dubbo-go copied to clipboard

[feat] protoc-gen-go-triple: Expose unary response headers and trailers in generated Triple client API

Open Alanxtl opened this issue 5 months ago • 3 comments

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:

  1. Add an optional call option that captures response metadata.
  2. Add a generated unary method variant that returns a response wrapper.
  3. 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.

Alanxtl avatar Jun 16 '26 06:06 Alanxtl

I would like to work on this , please assign to me

Vanillaxi avatar Jun 16 '26 11:06 Vanillaxi

I would like to work on this , please assign to me

sure

Alanxtl avatar Jun 16 '26 13:06 Alanxtl

close via #3443

Alanxtl avatar Jun 19 '26 08:06 Alanxtl