-
Notifications
You must be signed in to change notification settings - Fork 463
/
Copy pathgeneric_metadata.go
67 lines (54 loc) · 1.88 KB
/
generic_metadata.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package internal
import (
"time"
"github.com/wal-g/wal-g/pkg/storages/storage"
)
// GenericMetadata allows to obtain some basic information
// about existing backup in storage. It is useful when
// creating a functionality that is common to all databases,
// for example backup-list or backup-mark.
//
// To support the GenericMetadata in some particular database,
// one should write its own GenericMetaFetcher and GenericMetaSetter.
type GenericMetadata struct {
BackupName string
UncompressedSize int64
CompressedSize int64
Hostname string
StartTime time.Time
FinishTime time.Time
IsPermanent bool
IsIncremental bool
// need to use separate fetcher
// to avoid useless sentinel load (in Postgres)
IncrementDetails IncrementDetailsFetcher
UserData interface{}
}
// IncrementDetails is useful to fetch information about
// dependencies of some incremental backup
type IncrementDetails struct {
IncrementFrom string
IncrementFullName string
IncrementCount int
}
type IncrementDetailsFetcher interface {
Fetch() (isIncremental bool, details IncrementDetails, err error)
}
// GenericMetaInteractor is a combination of GenericMetaFetcher
// and GenericMetaSetter. It can be useful when need both.
type GenericMetaInteractor interface {
GenericMetaFetcher
GenericMetaSetter
}
type GenericMetaFetcher interface {
Fetch(backupName string, backupFolder storage.Folder) (GenericMetadata, error)
}
type GenericMetaSetter interface {
SetUserData(backupName string, backupFolder storage.Folder, userData interface{}) error
SetIsPermanent(backupName string, backupFolder storage.Folder, isPermanent bool) error
}
// NopIncrementDetailsFetcher is useful for databases without incremental backup support
type NopIncrementDetailsFetcher struct{}
func (idf *NopIncrementDetailsFetcher) Fetch() (bool, IncrementDetails, error) {
return false, IncrementDetails{}, nil
}