Documentation ¶
Index ¶
- Variables
- func ListSnapshots(dirpath string) ([]string, error)
- func ListWALs(dirpath string) ([]string, error)
- func MigrateSnapshot(oldDir, newDir string, oldFactory, newFactory SnapFactory) error
- func MigrateWALs(ctx context.Context, oldDir, newDir string, oldFactory, newFactory WALFactory, ...) error
- func ReadRepairWAL(ctx context.Context, walDir string, walsnap walpb.Snapshot, factory WALFactory) (WAL, WALData, error)
- type EncryptedRaftLogger
- func (e *EncryptedRaftLogger) BootstrapFromDisk(ctx context.Context, oldEncryptionKeys ...[]byte) (*raftpb.Snapshot, WALData, error)
- func (e *EncryptedRaftLogger) BootstrapNew(metadata []byte) error
- func (e *EncryptedRaftLogger) Clear(ctx context.Context) error
- func (e *EncryptedRaftLogger) Close(ctx context.Context)
- func (e *EncryptedRaftLogger) GC(index uint64, term uint64, keepOldSnapshots uint64) error
- func (e *EncryptedRaftLogger) RotateEncryptionKey(newKey []byte)
- func (e *EncryptedRaftLogger) SaveEntries(st raftpb.HardState, entries []raftpb.Entry) error
- func (e *EncryptedRaftLogger) SaveSnapshot(snapshot raftpb.Snapshot) error
- type SnapFactory
- type Snapshotter
- type WAL
- type WALData
- type WALFactory
Constants ¶
This section is empty.
Variables ¶
var ErrNoWAL = errors.New("no WAL present")
ErrNoWAL is returned if there are no WALs on disk
Functions ¶
func ListSnapshots ¶
ListSnapshots lists all the snapshot files in a particular directory and returns the snapshot files in reverse lexical order (newest first)
func ListWALs ¶
ListWALs lists all the wals in a directory and returns the list in lexical order (oldest first)
func MigrateSnapshot ¶
func MigrateSnapshot(oldDir, newDir string, oldFactory, newFactory SnapFactory) error
MigrateSnapshot reads the latest existing snapshot from one directory, encoded one way, and writes it to a new directory, encoded a different way
func MigrateWALs ¶
func MigrateWALs(ctx context.Context, oldDir, newDir string, oldFactory, newFactory WALFactory, snapshot walpb.Snapshot) error
MigrateWALs reads existing WALs (from a particular snapshot and beyond) from one directory, encoded one way, and writes them to a new directory, encoded a different way
Types ¶
type EncryptedRaftLogger ¶
type EncryptedRaftLogger struct { StateDir string EncryptionKey []byte // FIPS specifies whether the encryption should be FIPS-compliant FIPS bool // contains filtered or unexported fields }
EncryptedRaftLogger saves raft data to disk
func (*EncryptedRaftLogger) BootstrapFromDisk ¶
func (e *EncryptedRaftLogger) BootstrapFromDisk(ctx context.Context, oldEncryptionKeys ...[]byte) (*raftpb.Snapshot, WALData, error)
BootstrapFromDisk creates a new snapshotter and wal, and also reads the latest snapshot and WALs from disk
func (*EncryptedRaftLogger) BootstrapNew ¶
func (e *EncryptedRaftLogger) BootstrapNew(metadata []byte) error
BootstrapNew creates a new snapshotter and WAL writer, expecting that there is nothing on disk
func (*EncryptedRaftLogger) Clear ¶
func (e *EncryptedRaftLogger) Clear(ctx context.Context) error
Clear closes the existing WAL and removes the WAL and snapshot.
func (*EncryptedRaftLogger) Close ¶
func (e *EncryptedRaftLogger) Close(ctx context.Context)
Close closes the logger - it will have to be bootstrapped again to start writing
func (*EncryptedRaftLogger) GC ¶
func (e *EncryptedRaftLogger) GC(index uint64, term uint64, keepOldSnapshots uint64) error
GC garbage collects snapshots and wals older than the provided index and term
func (*EncryptedRaftLogger) RotateEncryptionKey ¶
func (e *EncryptedRaftLogger) RotateEncryptionKey(newKey []byte)
RotateEncryptionKey swaps out the encoders and decoders used by the wal and snapshotter
func (*EncryptedRaftLogger) SaveEntries ¶
SaveEntries saves only entries to disk
func (*EncryptedRaftLogger) SaveSnapshot ¶
func (e *EncryptedRaftLogger) SaveSnapshot(snapshot raftpb.Snapshot) error
SaveSnapshot actually saves a given snapshot to both the WAL and the snapshot.
type SnapFactory ¶
type SnapFactory interface {
New(dirpath string) Snapshotter
}
SnapFactory provides an interface for the different ways to get a Snapshotter object. For instance, the etcd/snap package itself provides this
var OriginalSnap SnapFactory = originalSnap{}
OriginalSnap is the original `snap` package as an implementation of the SnapFactory interface
func NewSnapFactory ¶
func NewSnapFactory(encrypter encryption.Encrypter, decrypter encryption.Decrypter) SnapFactory
NewSnapFactory returns a new object that can read from and write to encrypted snapshots on disk
type Snapshotter ¶
type Snapshotter interface { SaveSnap(snapshot raftpb.Snapshot) error Load() (*raftpb.Snapshot, error) }
Snapshotter is the interface presented by github.com/coreos/etcd/snap.Snapshotter that we depend upon
type WAL ¶
type WAL interface { ReadAll() ([]byte, raftpb.HardState, []raftpb.Entry, error) ReleaseLockTo(index uint64) error Close() error Save(st raftpb.HardState, ents []raftpb.Entry) error SaveSnapshot(e walpb.Snapshot) error }
WAL is the interface presented by github.com/coreos/etcd/wal.WAL that we depend upon
type WALData ¶
WALData contains all the data returned by a WAL's ReadAll() function (metadata, hardwate, and entries)
type WALFactory ¶
type WALFactory interface { Create(dirpath string, metadata []byte) (WAL, error) Open(dirpath string, walsnap walpb.Snapshot) (WAL, error) }
WALFactory provides an interface for the different ways to get a WAL object. For instance, the etcd/wal package itself provides this
var OriginalWAL WALFactory = originalWAL{}
OriginalWAL is the original `wal` package as an implementation of the WALFactory interface
func NewWALFactory ¶
func NewWALFactory(encrypter encryption.Encrypter, decrypter encryption.Decrypter) WALFactory
NewWALFactory returns an object that can be used to produce objects that will read from and write to encrypted WALs on disk.