Alanxtl opened a new issue, #3429:
URL: https://github.com/apache/dubbo-go/issues/3429

   ## Background
   
   Dubbo-Go Triple runtime already has support for unary response metadata 
through `triple_protocol.Response`:
   
   ```go
   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:
   
   ```go
   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:
   
   ```go
   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:
   
   ```go
   resp, err := cli.Greet(ctx, req, client.WithResponseHeader(header), 
client.WithResponseTrailer(trailer))
   ```
   
   or:
   
   ```go
   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.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to