File: discard_snapshot.go

package info (click to toggle)
golang-github-hashicorp-raft 0.0~git20160317.0.3359516-1~bpo8+1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 428 kB
  • sloc: makefile: 16
file content (48 lines) | stat: -rw-r--r-- 1,183 bytes parent folder | download | duplicates (3)
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
44
45
46
47
48
package raft

import (
	"fmt"
	"io"
)

// DiscardSnapshotStore is used to successfully snapshot while
// always discarding the snapshot. This is useful for when the
// log should be truncated but no snapshot should be retained.
// This should never be used for production use, and is only
// suitable for testing.
type DiscardSnapshotStore struct{}

type DiscardSnapshotSink struct{}

// NewDiscardSnapshotStore is used to create a new DiscardSnapshotStore.
func NewDiscardSnapshotStore() *DiscardSnapshotStore {
	return &DiscardSnapshotStore{}
}

func (d *DiscardSnapshotStore) Create(index, term uint64, peers []byte) (SnapshotSink, error) {
	return &DiscardSnapshotSink{}, nil
}

func (d *DiscardSnapshotStore) List() ([]*SnapshotMeta, error) {
	return nil, nil
}

func (d *DiscardSnapshotStore) Open(id string) (*SnapshotMeta, io.ReadCloser, error) {
	return nil, nil, fmt.Errorf("open is not supported")
}

func (d *DiscardSnapshotSink) Write(b []byte) (int, error) {
	return len(b), nil
}

func (d *DiscardSnapshotSink) Close() error {
	return nil
}

func (d *DiscardSnapshotSink) ID() string {
	return "discard"
}

func (d *DiscardSnapshotSink) Cancel() error {
	return nil
}