Skip to content

Commit

Permalink
backport of commit 8a0b8dc
Browse files Browse the repository at this point in the history
  • Loading branch information
tgross committed Mar 1, 2023
1 parent 5eaab12 commit bc0e4d0
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions nomad/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -765,17 +765,22 @@ func (s *Server) raftApplyFuture(t structs.MessageType, msg interface{}) (raft.A
// raftApplyFn is the function signature for applying a msg to Raft
type raftApplyFn func(t structs.MessageType, msg interface{}) (interface{}, uint64, error)

// raftApply is used to encode a message, run it through raft, and return
// the FSM response along with any errors
func (s *Server) raftApply(t structs.MessageType, msg interface{}) (interface{}, uint64, error) {
// raftApply is used to encode a message, run it through raft, and return the
// FSM response along with any errors. If the FSM.Apply response is an error it
// will be returned as the error return value with a nil response.
func (s *Server) raftApply(t structs.MessageType, msg any) (any, uint64, error) {
future, err := s.raftApplyFuture(t, msg)
if err != nil {
return nil, 0, err
}
if err := future.Error(); err != nil {
return nil, 0, err
}
return future.Response(), future.Index(), nil
resp := future.Response()
if err, ok := resp.(error); ok && err != nil {
return nil, future.Index(), err
}
return resp, future.Index(), nil
}

// setQueryMeta is used to populate the QueryMeta data for an RPC call
Expand Down

0 comments on commit bc0e4d0

Please sign in to comment.