fix potential error shadowing when leader apply log, but return nil instead of ApplyLogResponse
This commit is contained in:
1 parent
c3f419bbc5
commit
777e856d00
2 files changed
+5
-3
No files matched your search
+1
-1
@@ -103,7 +103,7 @@ func (client *Client) SyncApplyOnLeader(command []byte) (*ApplyLogResponse, erro
|
||||
return nil, fmt.Errorf("apply to raft as a leader: %v", err)
|
||||
}
|
||||
logResponse := apply.(ApplyLogResponse)
|
||||
return &logResponse, err
|
||||
return &logResponse, nil
|
||||
}
|
||||
|
||||
func (client *Client) listenLeader() {
|
||||
|
||||
+4
-2
@@ -1,6 +1,8 @@
|
||||
package subs
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
etp "github.com/integration-system/isp-etp-go/v2"
|
||||
log "github.com/integration-system/isp-log"
|
||||
"isp-config-service/cluster"
|
||||
@@ -14,8 +16,8 @@ func (h *SocketEventHandler) applyCommandOnLeader(_ etp.Conn, cmd []byte) (data
|
||||
obj, err := holder.ClusterClient.SyncApplyOnLeader(cmdCopy)
|
||||
if err != nil {
|
||||
var logResponse cluster.ApplyLogResponse
|
||||
logResponse.ApplyError = err.Error()
|
||||
data, err = json.Marshal(obj)
|
||||
logResponse.ApplyError = fmt.Sprintf("SyncApplyOnLeader: %v", err)
|
||||
data, err = json.Marshal(logResponse)
|
||||
if err != nil {
|
||||
log.Fatalf(codes.SyncApplyError, "marshaling ApplyLogResponse: %v", err)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user