@@ -24,7 +24,6 @@ import (
2424 "sync"
2525
2626 "google.golang.org/grpc/internal/serviceconfig"
27- "google.golang.org/grpc/metadata"
2827 "google.golang.org/grpc/resolver"
2928)
3029
@@ -52,82 +51,7 @@ type RPCConfig struct {
5251 Context context.Context
5352 MethodConfig serviceconfig.MethodConfig // configuration to use for this RPC
5453 OnCommitted func () // Called when the RPC has been committed (retries no longer possible)
55- Interceptor ClientInterceptor
56- }
57-
58- // ClientStream is the same as grpc.ClientStream, but defined here for circular
59- // dependency reasons.
60- type ClientStream interface {
61- // Header returns the header metadata received from the server if there
62- // is any. It blocks if the metadata is not ready to read.
63- Header () (metadata.MD , error )
64- // Trailer returns the trailer metadata from the server, if there is any.
65- // It must only be called after stream.CloseAndRecv has returned, or
66- // stream.Recv has returned a non-nil error (including io.EOF).
67- Trailer () metadata.MD
68- // CloseSend closes the send direction of the stream. It closes the stream
69- // when non-nil error is met. It is also not safe to call CloseSend
70- // concurrently with SendMsg.
71- CloseSend () error
72- // Context returns the context for this stream.
73- //
74- // It should not be called until after Header or RecvMsg has returned. Once
75- // called, subsequent client-side retries are disabled.
76- Context () context.Context
77- // SendMsg is generally called by generated code. On error, SendMsg aborts
78- // the stream. If the error was generated by the client, the status is
79- // returned directly; otherwise, io.EOF is returned and the status of
80- // the stream may be discovered using RecvMsg.
81- //
82- // SendMsg blocks until:
83- // - There is sufficient flow control to schedule m with the transport, or
84- // - The stream is done, or
85- // - The stream breaks.
86- //
87- // SendMsg does not wait until the message is received by the server. An
88- // untimely stream closure may result in lost messages. To ensure delivery,
89- // users should ensure the RPC completed successfully using RecvMsg.
90- //
91- // It is safe to have a goroutine calling SendMsg and another goroutine
92- // calling RecvMsg on the same stream at the same time, but it is not safe
93- // to call SendMsg on the same stream in different goroutines. It is also
94- // not safe to call CloseSend concurrently with SendMsg.
95- SendMsg (m any ) error
96- // RecvMsg blocks until it receives a message into m or the stream is
97- // done. It returns io.EOF when the stream completes successfully. On
98- // any other error, the stream is aborted and the error contains the RPC
99- // status.
100- //
101- // It is safe to have a goroutine calling SendMsg and another goroutine
102- // calling RecvMsg on the same stream at the same time, but it is not
103- // safe to call RecvMsg on the same stream in different goroutines.
104- RecvMsg (m any ) error
105- }
106-
107- // ClientInterceptor is an interceptor for gRPC client streams.
108- type ClientInterceptor interface {
109- // NewStream creates a ClientStream for an RPC.
110- //
111- // Implementations must delegate stream creation to the provided newStream
112- // function. To intercept or override stream behavior, implementations
113- // may wrap the ClientStream returned by the delegate.
114- //
115- // Note: RPCInfo.Context is currently unused and will be nil.
116- //
117- // The done function is invoked when the RPC has finished using its
118- // underlying connection or if a connection could not be assigned. Because
119- // interceptors operate at the application layer, RPC operations may
120- // continue on the ClientStream even after done has been called. The
121- // caller must ensure done is non-nil.
122- //
123- // To ensure RPC completion notifications propagate through the entire
124- // interceptor chain, implementations must ensure that the done function
125- // passed to the delegate newStream invokes the done function passed to
126- // NewStream.
127- NewStream (ctx context.Context , ri RPCInfo , done func (), newStream func (ctx context.Context , done func ()) (ClientStream , error )) (ClientStream , error )
128- // Close closes the interceptor. Once called, no new calls to NewStream are
129- // accepted. Ongoing calls to NewStream are allowed to complete.
130- Close ()
54+ Interceptor any
13155}
13256
13357// ServerInterceptor is an interceptor for incoming RPC's on gRPC server side.
0 commit comments