Refactor Paxos status call to remove type assertion

This commit is contained in:
Bryan Boreham committed 2016-04-07 12:12:08 +01:00
1 parent 768e2a31fa
commit 0c59de40e7
4 files changed
+14 -6

No files matched your search

+5
View File
@@ -7,6 +7,7 @@ type Participant interface {
Propose()
Think() bool
Consensus() (bool, AcceptedValue)
IsElector() bool
}
type Observer struct {
@@ -37,3 +38,7 @@ func (observer *Observer) Think() bool {
func (observer *Observer) Consensus() (bool, AcceptedValue) {
return false, AcceptedValue{}
}
func (observer *Observer) IsElector() bool {
return false
}
+4 -3
View File
@@ -257,14 +257,15 @@ func (node *Node) Consensus() (bool, AcceptedValue) {
return false, AcceptedValue{}
}
func (node *Node) IsElector() bool {
return true
}
type Status struct {
KnownNodes int
Quorum uint
}
func NewStatus(node *Node) *Status {
if node == nil {
return nil
}
return &Status{len(node.knows), node.quorum}
}