generated from danthegoodman1/GoAPITemplate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
5 changed files
with
113 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package raft | ||
|
||
import ( | ||
"github.com/lni/dragonboat/v3" | ||
"sync/atomic" | ||
) | ||
|
||
type ( | ||
EpochHost struct { | ||
nodeHost *dragonboat.NodeHost | ||
|
||
// The monotonic incrementing index of a single epoch. | ||
// Each request must be servied a unique (lastEpoch, epochIndex) value | ||
epochIndex atomic.Uint64 | ||
|
||
// lastEpoch was the last epoch that we served to a request, | ||
// used to check whether we need to swap the epoch index | ||
lastEpoch atomic.Uint64 | ||
} | ||
) | ||
|
||
// GetLeader returns the leader node ID of the specified Raft cluster based | ||
// on local node's knowledge. The returned boolean value indicates whether the | ||
// leader information is available. | ||
func (e *EpochHost) GetLeader() (uint64, bool, error) { | ||
return e.nodeHost.GetLeaderID(ClusterID) | ||
} | ||
|
||
func (e *EpochHost) Stop() { | ||
e.nodeHost.Stop() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters