@@ -16,10 +16,10 @@ import (
1616
1717// Message direction constants
1818const (
19- DirectionSend = "send "
20- DirectionRecv = "recv "
21- DirectionServerSend = "server_send"
22- DirectionServerRecv = "server_recv "
19+ DirectionRequest = "request "
20+ DirectionResponse = "response "
21+ DirectionServerRequest = "server_request" // For server-initiated streams
22+ DirectionServerResponse = "server_response "
2323)
2424
2525// ReplicationStreamRecorder captures replication stream messages for testing
@@ -115,7 +115,7 @@ func (r *ReplicationStreamRecorder) recordMessage(method string, msg proto.Messa
115115 }
116116
117117 // Store the message reference directly without cloning for performance
118- if direction == DirectionSend || direction == DirectionServerSend {
118+ if direction == DirectionRequest || direction == DirectionServerRequest {
119119 captured .Request = msg
120120 } else {
121121 captured .Response = msg
@@ -128,7 +128,7 @@ func (r *ReplicationStreamRecorder) recordMessage(method string, msg proto.Messa
128128func (r * ReplicationStreamRecorder ) formatCapturedMessage (captured CapturedReplicationMessage ) string {
129129 // Get the appropriate proto message based on direction
130130 var msg proto.Message
131- if captured .Direction == DirectionSend || captured .Direction == DirectionServerSend {
131+ if captured .Direction == DirectionRequest || captured .Direction == DirectionServerRequest {
132132 msg = captured .Request
133133 } else {
134134 msg = captured .Response
@@ -170,7 +170,7 @@ func (r *ReplicationStreamRecorder) UnaryInterceptor(clusterName string) grpc.Un
170170 // Capture outgoing request if it's a replication-related call
171171 if isReplicationMethod (method ) {
172172 if protoReq , ok := req .(proto.Message ); ok {
173- r .recordMessage (method , protoReq , DirectionSend , clusterName , target , false )
173+ r .recordMessage (method , protoReq , DirectionRequest , clusterName , target , false )
174174 }
175175 }
176176
@@ -179,7 +179,7 @@ func (r *ReplicationStreamRecorder) UnaryInterceptor(clusterName string) grpc.Un
179179 // Capture incoming response if successful
180180 if err == nil && isReplicationMethod (method ) {
181181 if protoReply , ok := reply .(proto.Message ); ok {
182- r .recordMessage (method , protoReply , DirectionRecv , clusterName , target , false )
182+ r .recordMessage (method , protoReply , DirectionResponse , clusterName , target , false )
183183 }
184184 }
185185
@@ -228,7 +228,7 @@ type recordingClientStream struct {
228228func (s * recordingClientStream ) SendMsg (m interface {}) error {
229229 if msg , ok := m .(proto.Message ); ok {
230230 // SendMsg means this cluster is SENDING a message (could be request or ack)
231- s .recorder .recordMessage (s .method , msg , DirectionSend , s .clusterName , s .targetAddress , true )
231+ s .recorder .recordMessage (s .method , msg , DirectionRequest , s .clusterName , s .targetAddress , true )
232232 }
233233 return s .ClientStream .SendMsg (m )
234234}
@@ -238,7 +238,7 @@ func (s *recordingClientStream) RecvMsg(m interface{}) error {
238238 if err == nil {
239239 if msg , ok := m .(proto.Message ); ok {
240240 // RecvMsg means this cluster is RECEIVING a message (could be request or data)
241- s .recorder .recordMessage (s .method , msg , DirectionRecv , s .clusterName , s .targetAddress , true )
241+ s .recorder .recordMessage (s .method , msg , DirectionResponse , s .clusterName , s .targetAddress , true )
242242 }
243243 }
244244 return err
@@ -255,7 +255,7 @@ func (r *ReplicationStreamRecorder) UnaryServerInterceptor(clusterName string) g
255255 // Capture incoming request if it's a replication-related call
256256 if isReplicationMethod (info .FullMethod ) {
257257 if protoReq , ok := req .(proto.Message ); ok {
258- r .recordMessage (info .FullMethod , protoReq , DirectionServerRecv , clusterName , "server" , false )
258+ r .recordMessage (info .FullMethod , protoReq , DirectionServerRequest , clusterName , "server" , false )
259259 }
260260 }
261261
@@ -264,7 +264,7 @@ func (r *ReplicationStreamRecorder) UnaryServerInterceptor(clusterName string) g
264264 // Capture outgoing response if successful
265265 if err == nil && isReplicationMethod (info .FullMethod ) {
266266 if protoResp , ok := resp .(proto.Message ); ok {
267- r .recordMessage (info .FullMethod , protoResp , DirectionServerSend , clusterName , "server" , false )
267+ r .recordMessage (info .FullMethod , protoResp , DirectionServerResponse , clusterName , "server" , false )
268268 }
269269 }
270270
@@ -305,7 +305,7 @@ type recordingServerStream struct {
305305func (s * recordingServerStream ) SendMsg (m interface {}) error {
306306 if msg , ok := m .(proto.Message ); ok {
307307 // Server SendMsg means this server is SENDING a message to the client
308- s .recorder .recordMessage (s .method , msg , DirectionServerSend , s .clusterName , "server" , true )
308+ s .recorder .recordMessage (s .method , msg , DirectionServerResponse , s .clusterName , "server" , true )
309309 }
310310 return s .ServerStream .SendMsg (m )
311311}
@@ -315,7 +315,7 @@ func (s *recordingServerStream) RecvMsg(m interface{}) error {
315315 if err == nil {
316316 if msg , ok := m .(proto.Message ); ok {
317317 // Server RecvMsg means this server is RECEIVING a message from the client
318- s .recorder .recordMessage (s .method , msg , DirectionServerRecv , s .clusterName , "server" , true )
318+ s .recorder .recordMessage (s .method , msg , DirectionServerRequest , s .clusterName , "server" , true )
319319 }
320320 }
321321 return err
0 commit comments