@@ -16,26 +16,26 @@ import (
1616func UnaryClientInterceptor () grpc.UnaryClientInterceptor {
1717 log := logrus .StandardLogger ().WithField ("type" , "protobuf/validation/interceptor" )
1818
19- return func (ctx context.Context , method string , req , reply interface {}, cc * grpc.ClientConn , invoker grpc.UnaryInvoker , opts ... grpc.CallOption ) error {
19+ return func (ctx context.Context , method string , req , resp interface {}, cc * grpc.ClientConn , invoker grpc.UnaryInvoker , opts ... grpc.CallOption ) error {
2020 // Validate request
2121 if v , ok := req .(Validator ); ok {
2222 if err := v .Validate (); err != nil {
2323 // Log warn since the caller is at fault.
24- log .WithError (err ).Warn ("dropping invalid request" )
24+ log .WithError (err ).WithField ( "req" , req ). Warn ("dropping invalid request" )
2525 return status .Errorf (codes .InvalidArgument , err .Error ())
2626 }
2727 }
2828
2929 // Do service call
30- if err := invoker (ctx , method , req , reply , cc , opts ... ); err != nil {
30+ if err := invoker (ctx , method , req , resp , cc , opts ... ); err != nil {
3131 return err
3232 }
3333
3434 // Validate service response
35- if v , ok := reply .(Validator ); ok {
35+ if v , ok := resp .(Validator ); ok {
3636 if err := v .Validate (); err != nil {
37- // Just log debug here since the outbound service is mis-behaving.
38- log .WithError (err ).Debug ("dropping invalid response" )
37+ // Just log info here since the outbound service is mis-behaving.
38+ log .WithError (err ).WithField ( "resp" , resp ). Info ("dropping invalid response" )
3939 return status .Errorf (codes .Internal , err .Error ())
4040 }
4141 }
@@ -73,24 +73,24 @@ func (c *clientStreamWrapper) SendMsg(req interface{}) error {
7373 if v , ok := req .(Validator ); ok {
7474 if err := v .Validate (); err != nil {
7575 // Log warn since the caller is at fault.
76- c .log .WithError (err ).Warn ("dropping invalid request" )
76+ c .log .WithError (err ).WithField ( "req" , req ). Warn ("dropping invalid request" )
7777 return status .Errorf (codes .InvalidArgument , err .Error ())
7878 }
7979 }
8080
8181 return c .ClientStream .SendMsg (req )
8282}
8383
84- func (c * clientStreamWrapper ) RecvMsg (res interface {}) error {
85- if err := c .ClientStream .RecvMsg (res ); err != nil {
84+ func (c * clientStreamWrapper ) RecvMsg (resp interface {}) error {
85+ if err := c .ClientStream .RecvMsg (resp ); err != nil {
8686 return err
8787 }
8888
8989 // Validate service response
90- if v , ok := res .(Validator ); ok {
90+ if v , ok := resp .(Validator ); ok {
9191 if err := v .Validate (); err != nil {
92- // Just log debug here since the outbound service is mis-behaving.
93- c .log .WithError (err ).Debug ("dropping invalid response" )
92+ // Just log info here since the outbound service is mis-behaving.
93+ c .log .WithError (err ).WithField ( "resp" , resp ). Info ("dropping invalid response" )
9494 return status .Errorf (codes .Internal , err .Error ())
9595 }
9696 }
0 commit comments