...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package mockstorage
16
17 import (
18 "go.etcd.io/etcd/client/pkg/v3/testutil"
19 "go.etcd.io/etcd/raft/v3"
20 "go.etcd.io/etcd/raft/v3/raftpb"
21 )
22
23 type storageRecorder struct {
24 testutil.Recorder
25 dbPath string
26 }
27
28 func NewStorageRecorder(db string) *storageRecorder {
29 return &storageRecorder{&testutil.RecorderBuffered{}, db}
30 }
31
32 func NewStorageRecorderStream(db string) *storageRecorder {
33 return &storageRecorder{testutil.NewRecorderStream(), db}
34 }
35
36 func (p *storageRecorder) Save(st raftpb.HardState, ents []raftpb.Entry) error {
37 p.Record(testutil.Action{Name: "Save"})
38 return nil
39 }
40
41 func (p *storageRecorder) SaveSnap(st raftpb.Snapshot) error {
42 if !raft.IsEmptySnap(st) {
43 p.Record(testutil.Action{Name: "SaveSnap"})
44 }
45 return nil
46 }
47
48 func (p *storageRecorder) Release(st raftpb.Snapshot) error {
49 if !raft.IsEmptySnap(st) {
50 p.Record(testutil.Action{Name: "Release"})
51 }
52 return nil
53 }
54
55 func (p *storageRecorder) Sync() error {
56 p.Record(testutil.Action{Name: "Sync"})
57 return nil
58 }
59
60 func (p *storageRecorder) Close() error { return nil }
61
View as plain text