Преглед изворни кода

bump(github.com/coreos/raft): 0c36c972a25343e7e353257284ef6df5c8676a3d

Ben Johnson пре 12 година
родитељ
комит
4ff773aaaf

+ 7 - 0
third_party/github.com/coreos/raft/context.go

@@ -7,6 +7,7 @@ type Context interface {
 	Server() Server
 	CurrentTerm() uint64
 	CurrentIndex() uint64
+	CommitIndex() uint64
 }
 
 // context is the concrete implementation of Context.
@@ -14,6 +15,7 @@ type context struct {
 	server       Server
 	currentIndex uint64
 	currentTerm  uint64
+	commitIndex  uint64
 }
 
 // Server returns a reference to the server.
@@ -30,3 +32,8 @@ func (c *context) CurrentTerm() uint64 {
 func (c *context) CurrentIndex() uint64 {
 	return c.currentIndex
 }
+
+// CommitIndex returns last commit index the server is at.
+func (c *context) CommitIndex() uint64 {
+	return c.commitIndex
+}

+ 6 - 1
third_party/github.com/coreos/raft/server.go

@@ -173,7 +173,12 @@ func NewServer(name string, path string, transporter Transporter, stateMachine S
 	s.log.ApplyFunc = func(c Command) (interface{}, error) {
 		switch c := c.(type) {
 		case CommandApply:
-			return c.Apply(&context{server: s, currentTerm: s.currentTerm, currentIndex: s.log.currentIndex()})
+			return c.Apply(&context{
+				server:       s,
+				currentTerm:  s.currentTerm,
+				currentIndex: s.log.currentIndex(),
+				commitIndex:  s.log.commitIndex,
+			})
 		case deprecatedCommandApply:
 			return c.Apply(s)
 		default: