Skip to content

Commit

Permalink
Improve code
Browse files Browse the repository at this point in the history
  • Loading branch information
liuh-80 committed Jul 12, 2024
1 parent 5537394 commit df04cb0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions sonic_data_client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ func TestRetryHelper(t *testing.T) {
exeCount++
if returnError {
returnError = false
return fmt.Errorf("connection_reset")
return fmt.Errorf("zmq connection break, endpoint: tcp://127.0.0.1:2234")
}
return nil
})
Expand Down Expand Up @@ -596,7 +596,7 @@ func TestRetryHelperReconnect(t *testing.T) {
func () (err error) {
exeCount++
if exeCount <= 6 {
return fmt.Errorf("connection_reset")
return fmt.Errorf("zmq connection break, endpoint: tcp://127.0.0.1:2234")
}
return nil
})
Expand Down
4 changes: 2 additions & 2 deletions sonic_data_client/mixed_db_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,11 +288,11 @@ type ActionNeedRetry func() error
func RetryHelper(zmqClient swsscommon.ZmqClient, action ActionNeedRetry) error {
var retry uint = 0
var retry_delay = time.Duration(RETRY_DELAY_MILLISECOND) * time.Millisecond
ConnectionResetErr := "connection_reset"
ConnectionResetErr := "zmq connection break"
for {
err := action()
if err != nil {
if (err.Error() == ConnectionResetErr) {
if strings.Contains(err.Error(), ConnectionResetErr) {
if (retry <= MAX_RETRY_COUNT) {
log.V(6).Infof("RetryHelper: connection reset, reconnect and retry later")
time.Sleep(retry_delay)
Expand Down

0 comments on commit df04cb0

Please sign in to comment.