aboutsummaryrefslogtreecommitdiff
path: root/object/store/quarantiner.go
blob: 467d5c3546fa1e8714c1565dce10dd2b5f983ea6 (about) (plain) (blame)
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package store

// QuarantineBase is one quarantined write.
// It is intended to be embedded.
type QuarantineBase interface {
	// Reader exposes the objects written into this quarantine.
	ObjectReader

	// Promote publishes quarantined writes into their final destination.
	//
	// Promote is not atomic.
	// Because objects are content-addressed and immutable,
	// a partial promotion is safe:
	// it only makes some objects visible early,
	// which is harmless until a ref references them.
	//
	// Promote invalidates the receiver.
	Promote() error

	// Discard abandons quarantined writes.
	//
	// Discard invalidates the receiver.
	Discard() error
}

// ObjectQuarantine represents one quarantined object-wise write.
type ObjectQuarantine interface {
	QuarantineBase
	ObjectWriter
}

// ObjectQuarantineOptions controls the options
// for one object quarantine creation.
type ObjectQuarantineOptions struct{}

// ObjectQuarantiner creates quarantines
// for object-wise writes.
type ObjectQuarantiner interface {
	BeginObjectQuarantine(opts ObjectQuarantineOptions) (ObjectQuarantine, error)
}

// PackQuarantine represents one quarantined pack-wise write.
type PackQuarantine interface {
	QuarantineBase
	PackWriter
}

// PackQuarantineOptions controls the options
// for one pack quarantine creation.
type PackQuarantineOptions struct{}

// PackQuarantiner creates quarantines
// for pack-wise writes.
type PackQuarantiner interface {
	BeginPackQuarantine(opts PackQuarantineOptions) (PackQuarantine, error)
}

// CoordinatedQuarantine represents one quarantine
// that accepts both object-wise and pack-wise writes
// behind a single Promote/Discard.
type CoordinatedQuarantine interface {
	ObjectQuarantine
	PackQuarantine
}

// CoordinatedQuarantineOptions controls the options
// for one coordinated quarantine creation.
type CoordinatedQuarantineOptions struct {
	Object ObjectQuarantineOptions
	Pack   PackQuarantineOptions
}

// CoordinatedQuarantiner creates coordinated quarantines
// that accept both object-wise and pack-wise writes
// behind a single Promote/Discard.
//
// The returned quarantine is usable
// anywhere either split quarantine is expected.
type CoordinatedQuarantiner interface {
	BeginCoordinatedQuarantine(opts CoordinatedQuarantineOptions) (CoordinatedQuarantine, error)
}