forked from hashicorp/raft
-
Notifications
You must be signed in to change notification settings - Fork 0
/
peer.go
33 lines (27 loc) · 842 Bytes
/
peer.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package raft
import (
"net"
)
// PeerStore provides an interface for persistent storage and
// retrieval of peers. We use a seperate interface than StableStore
// since the peers may need to be editted by a human operator. For example,
// in a two node cluster, the failure of either node requires human intervention
// since consensus is impossible.
type PeerStore interface {
// Returns the list of known peers
Peers() ([]net.Addr, error)
// Sets the list of known peers. This is invoked when
// a peer is added or removed
SetPeers([]net.Addr) error
}
// StatisPeers is used to provide a static list of peers
type StaticPeers struct {
StaticPeers []net.Addr
}
func (s *StaticPeers) Peers() ([]net.Addr, error) {
return s.StaticPeers, nil
}
func (s *StaticPeers) SetPeers(p []net.Addr) error {
s.StaticPeers = p
return nil
}