forked from coreos/torus
/
empty.go
43 lines (34 loc) · 844 Bytes
/
empty.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
34
35
36
37
38
39
40
41
42
43
package ring
import (
"github.com/coreos/torus"
"github.com/coreos/torus/models"
)
type empty struct {
version int
}
func init() {
registerRing(Empty, "empty", makeEmpty)
}
func makeEmpty(r *models.Ring) (torus.Ring, error) {
return &empty{
version: int(r.Version),
}, nil
}
func (e *empty) GetPeers(key torus.BlockRef) (torus.PeerPermutation, error) {
return torus.PeerPermutation{
Peers: []string{},
Replication: 0,
}, nil
}
func (e *empty) Members() torus.PeerList { return []string{} }
func (e *empty) Describe() string {
return "Ring: Empty"
}
func (e *empty) Type() torus.RingType { return Empty }
func (e *empty) Version() int { return e.version }
func (e *empty) Marshal() ([]byte, error) {
var out models.Ring
out.Version = uint32(e.version)
out.Type = uint32(e.Type())
return out.Marshal()
}