Skip to content

Commit

Permalink
Document how FSM.Apply errors are retrieved from a Future
Browse files Browse the repository at this point in the history
  • Loading branch information
dnephin committed Apr 9, 2021
1 parent aee4d86 commit c2ad9a3
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions future.go
Expand Up @@ -9,12 +9,13 @@ import (

// Future is used to represent an action that may occur in the future.
type Future interface {
// Error blocks until the future arrives and then
// returns the error status of the future.
// This may be called any number of times - all
// calls will return the same value.
// Note that it is not OK to call this method
// twice concurrently on the same Future instance.
// Error blocks until the future arrives and then returns the error status
// of the future. This may be called any number of times - all calls will
// return the same value, however is not OK to call this method twice
// concurrently on the same Future instance.
// Error will only return generic errors related to raft, such
// as ErrLeadershipLost, or ErrRaftShutdown. Some operations, such as
// ApplyLog, may also return errors from other methods.
Error() error
}

Expand All @@ -32,9 +33,11 @@ type IndexFuture interface {
type ApplyFuture interface {
IndexFuture

// Response returns the FSM response as returned
// by the FSM.Apply method. This must not be called
// until after the Error method has returned.
// Response returns the FSM response as returned by the FSM.Apply method. This
// must not be called until after the Error method has returned.
// Note that if FSM.Apply returns an error, it will be returned by Response,
// and not by the Error method, so it is always important to check Response
// for errors from the FSM.
Response() interface{}
}

Expand Down

0 comments on commit c2ad9a3

Please sign in to comment.