-
Notifications
You must be signed in to change notification settings - Fork 0
/
send.go
67 lines (56 loc) · 1.28 KB
/
send.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 job
import (
"context"
"time"
)
// ZFSSend represents a ZFS send process
type ZFSSend interface {
// Dataset returns the full Dataset(=Snapshot) that is sent
Dataset() string
// DatasetName returns the dataset name
DatasetName() string
// SnapshotName returns the snapshot name
SnapshotName() string
// Server returns the URL the snapshot is being sent to
Server() string
// BytesSent returns how many bytes have been sent
BytesSent() int64
// UpdatedAt returns when this was last updated
UpdatedAt() time.Time
// StartedAt returns when send was started
StartedAt() time.Time
// CancelSend cancels the send process
CancelSend()
}
type zfsSend struct {
dataset string
server string
bytesSent int64
started time.Time
updated time.Time
cancel context.CancelFunc
}
func (z zfsSend) Dataset() string {
return z.dataset
}
func (z zfsSend) DatasetName() string {
return datasetName(z.dataset, true)
}
func (z zfsSend) SnapshotName() string {
return snapshotName(z.dataset)
}
func (z zfsSend) Server() string {
return z.server
}
func (z zfsSend) BytesSent() int64 {
return z.bytesSent
}
func (z zfsSend) UpdatedAt() time.Time {
return z.updated
}
func (z zfsSend) StartedAt() time.Time {
return z.started
}
func (z zfsSend) CancelSend() {
z.cancel()
}