lizining1231 opened a new pull request, #3663:
URL: https://github.com/apache/dubbo-go/pull/3663

   ### Description
   Fixes #3644 (task 9)
   This PR adds doc comments for the Triple stream exported APIs, clarifying 
their behavior, error return conditions, stop semantics, and metadata handling. 
It also adds 20 boundary tests covering stream close, repeated close, error 
propagation and empty metadata.
   
   ### Changes
   
   - **client_stream.go**
     - `CloseAndReceive`: doc comment enhanced — closes the receive side before 
returning an error, whether closing the send side or receiving the response 
fails.
     - `ServerStreamForClient.Receive`: documents the stop semantics — once 
Receive has returned false, subsequent calls return false without advancing the 
stream.
     - `ServerStreamForClient.Close`: returns the construction error when the 
stream could not be constructed.
     - `ServerStreamForClient.Msg`: aligned with the handler side — returns nil 
if Receive has not been called, and the message may be left unmarshaled after a 
failed Receive.
     - `BidiStreamForClient.Receive`: returns the underlying receive error 
unchanged.
   - **handler_stream.go**
     - `ClientStream.Receive`: documents the same stop semantics as the client 
side.
     - `ClientStream.Msg`: documents the failure semantics of the returned 
message.
     - `ServerStream.Send` / `BidiStream.Send`: fixed the misleading comment — 
a nil msg does not send an empty message, it commits the response headers 
without writing a message frame.
     - `BidiStream.ExportableHeader`: clarified that the underlying protocol 
decides which headers are exported; under the gRPC protocol reserved headers 
are filtered out (except the whitelisted ones) and keys are lowercased.
   - **handler_stream_compat.go**
     - `NewCompatStreamHandler`: new doc comment. Describes the 
`grpc.ServerStream` adaptation, the metadata and `TripleGoInterfaceName` values 
injected into the context, the interceptor wrapping order (the interceptor 
wraps the whole implementation, so it runs before the metadata injection), and 
the fact that `SetHeader` / `SendHeader` / `SetTrailer` on the adapted stream 
are no-ops.
   
   **client_stream_test.go (11 new tests):**
   
   | Test | What it verifies |
   | --- | --- |
   | `TestServerStreamForClientClose` | `Close` delegates to `CloseResponse` 
and returns its result |
   | `TestServerStreamForClientCloseRepeated` | Calling `Close` more than once 
keeps delegating |
   | `TestServerStreamForClientErrPropagation` | `Err` returns the first 
non-EOF error and nil for a normal end of stream (EOF) |
   | `TestServerStreamForClientReceiveStopsAfterError` | Once an error is 
recorded, subsequent `Receive` calls return false without advancing the 
connection |
   | `TestServerStreamForClientEmptyMetadata` | `ResponseHeader` / 
`ResponseTrailer` return empty headers |
   | `TestBidiStreamForClientReceiveErrorPropagation` | `Receive` returns the 
underlying connection error unchanged |
   | `TestBidiStreamForClientRequestHeaderEmpty` | `RequestHeader` returns an 
empty header |
   | `TestBidiStreamForClientCloseRequestRepeated` | Calling `CloseRequest` 
more than once keeps delegating |
   | `TestBidiStreamForClientCloseResponseRepeated` | Calling `CloseResponse` 
more than once keeps delegating |
   | 
`TestClientStreamForClientCloseAndReceiveClosesResponseOnCloseRequestError` | 
`CloseAndReceive` closes the receive side before returning the error when 
closing the send side fails |
   | `TestClientStreamForClientCloseAndReceiveClosesResponseOnReceiveError` | 
`CloseAndReceive` closes the receive side before returning the error when 
receiving the response fails |
   
   **handler_stream_test.go (9 tests):**
   
   | Test | What it verifies |
   | --- | --- |
   | `TestClientStreamReceiveStopsAfterError` | Once an error is recorded, 
subsequent `Receive` calls return false without advancing the connection |
   | `TestClientStreamErrPropagation` | `Err` returns the first non-EOF error 
and nil for a normal end of stream (EOF) |
   | `TestClientStreamMsgNil` | `Msg` returns nil when `Receive` has not been 
called |
   | `TestClientStreamRequestHeaderEmpty` | `RequestHeader` returns an empty 
header |
   | `TestServerStreamSendNil` | `Send` delegates a nil msg to the underlying 
connection unchanged |
   | `TestServerStreamResponseHeaderEmpty` | `ResponseHeader` / 
`ResponseTrailer` return empty headers |
   | `TestBidiStreamReceiveErrorPropagation` | `Receive` returns the underlying 
connection error unchanged |
   | `TestBidiStreamSendNil` | `Send` delegates a nil msg to the underlying 
connection unchanged |
   | `TestBidiStreamExportableHeader` | `ExportableHeader` forwards the 
underlying connection's metadata unchanged |
   
   
   ### Checklist
   - [x] I confirm the target branch is `develop`
   - [x] I have run `make fmt` to format my code
   - [x] I have run `make test` to run local tests
   - [x] I have added tests that prove my fix is effective or that my feature 
works
   


-- 
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