@@ -49,7 +49,7 @@ type V1Instance struct {
4949 global * globalManager
5050 mutliRegion * mutliRegionManager
5151 peerMutex sync.RWMutex
52- log logrus. FieldLogger
52+ log FieldLogger
5353 conf Config
5454 isClosed bool
5555 getRateLimitsCounter int64
@@ -175,16 +175,14 @@ func (s *V1Instance) Close() (reterr error) {
175175
176176 err := s .gubernatorPool .Store (ctx )
177177 if err != nil {
178- logrus .WithContext (ctx ).
179- WithError (err ).
178+ s .log .WithError (err ).
180179 Error ("Error in checkHandlerPool.Store" )
181180 return errors .Wrap (err , "Error in checkHandlerPool.Store" )
182181 }
183182
184183 err = s .gubernatorPool .Close ()
185184 if err != nil {
186- logrus .WithContext (ctx ).
187- WithError (err ).
185+ s .log .WithError (err ).
188186 Error ("Error in checkHandlerPool.Close" )
189187 return errors .Wrap (err , "Error in checkHandlerPool.Close" )
190188 }
@@ -356,7 +354,7 @@ func (s *V1Instance) asyncRequests(ctx context.Context, req *AsyncReq) {
356354
357355 for {
358356 if attempts > 5 {
359- logrus .WithContext (ctx ).
357+ s . log .WithContext (ctx ).
360358 WithError (err ).
361359 WithField ("key" , req .Key ).
362360 Error ("GetPeer() returned peer that is not connected" )
@@ -366,13 +364,13 @@ func (s *V1Instance) asyncRequests(ctx context.Context, req *AsyncReq) {
366364 break
367365 }
368366
369- // If we are attempting again, the owner of the this rate limit might have changed to us!
367+ // If we are attempting again, the owner of this rate limit might have changed to us!
370368 if attempts != 0 {
371369 if req .Peer .Info ().IsOwner {
372370 getRateLimitCounter .WithLabelValues ("local" ).Add (1 )
373371 resp .Resp , err = s .getRateLimit (ctx , req .Req )
374372 if err != nil {
375- logrus .WithContext (ctx ).
373+ s . log .WithContext (ctx ).
376374 WithError (err ).
377375 WithField ("key" , req .Key ).
378376 Error ("Error applying rate limit" )
@@ -393,10 +391,7 @@ func (s *V1Instance) asyncRequests(ctx context.Context, req *AsyncReq) {
393391 req .Peer , err = s .GetPeer (ctx , req .Key )
394392 if err != nil {
395393 errPart := fmt .Sprintf ("Error finding peer that owns rate limit '%s'" , req .Key )
396- logrus .WithContext (ctx ).
397- WithError (err ).
398- WithField ("key" , req .Key ).
399- Error (errPart )
394+ s .log .WithContext (ctx ).WithError (err ).WithField ("key" , req .Key ).Error (errPart )
400395 countError (err , "Error in GetPeer" )
401396 err = errors .Wrap (err , errPart )
402397 resp .Resp = & RateLimitResp {Error : err .Error ()}
@@ -405,10 +400,6 @@ func (s *V1Instance) asyncRequests(ctx context.Context, req *AsyncReq) {
405400 continue
406401 }
407402
408- logrus .WithContext (ctx ).
409- WithError (err ).
410- WithField ("key" , req .Key ).
411- Error ("Error fetching rate limit from peer" )
412403 // Not calling `countError()` because we expect the remote end to
413404 // report this error.
414405 err = errors .Wrap (err , fmt .Sprintf ("Error while fetching rate limit '%s' from peer" , req .Key ))
@@ -676,6 +667,7 @@ func (s *V1Instance) SetPeers(peerInfo []PeerInfo) {
676667 peer = NewPeerClient (PeerConfig {
677668 TLS : s .conf .PeerTLS ,
678669 Behavior : s .conf .Behaviors ,
670+ Log : s .log ,
679671 Info : info ,
680672 })
681673 }
@@ -688,6 +680,7 @@ func (s *V1Instance) SetPeers(peerInfo []PeerInfo) {
688680 peer = NewPeerClient (PeerConfig {
689681 TLS : s .conf .PeerTLS ,
690682 Behavior : s .conf .Behaviors ,
683+ Log : s .log ,
691684 Info : info ,
692685 })
693686 }
0 commit comments