-
Notifications
You must be signed in to change notification settings - Fork 1
/
snapshot.go
43 lines (37 loc) · 955 Bytes
/
snapshot.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 skizze
import (
"log"
pb "github.com/skizzehq/goskizze/protobuf"
)
// SnapshotState indicates the state of the current or previous snapshot.
type SnapshotState int
const (
// Pending indicates a snapshot is waiting to be taken.
Pending SnapshotState = iota
// InProgress indicates a snapshot is currently being taken.
InProgress
// Successful indicates the last snapshot was successful.
Successful
// Failed indicates the last snapshot had an error.
Failed
)
// Snapshot represents details of the a snapshot
type Snapshot struct {
Status SnapshotState
Message string
}
func snapshotStatusFromRaw(s pb.SnapshotStatus) SnapshotState {
switch s {
case pb.SnapshotStatus_PENDING:
return Pending
case pb.SnapshotStatus_IN_PROGRESS:
return InProgress
case pb.SnapshotStatus_SUCCESSFUL:
return Successful
case pb.SnapshotStatus_FAILED:
return Failed
default:
log.Panicf("Snapshot status %v unknown", s)
return 0
}
}