-
Notifications
You must be signed in to change notification settings - Fork 1
/
sink.go
50 lines (42 loc) · 1.34 KB
/
sink.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
package wal
import "io"
// Sink defines the interface of a type that can persist, and subsequently
// load, write-ahead logging segments.
type Sink interface {
Analyzer
SegmentLoader
SegmentWriter
io.Closer
// Offsets returns the first, and last (most-recent) offsets known
// to a Sink.
Offsets() (first Offset, last Offset)
// NumSegments returns the number of segments currently known to
// the sink.
NumSegments() int
// Truncate permanently deletes all data chunks prior to the given
// offset.
Truncate(Offset) error
}
// Analyzer defines the interface of a type that can perform analysis on a
// persistent storage medium for write-ahead logs.
type Analyzer interface {
Analyze() error
}
// SegmentLoader defines the interface of a type that can retrieve segments
// from their persistent storage medium.
type SegmentLoader interface {
// LoadSegment returns the WAL segment containing the given Offset.
//
// If ZeroOffset is specified, then the segment with the lowest
// offset will be returned.
//
// Should the given offset be greater than one contained in any
// available segments, no segment will be returned, and err will be
// io.EOF.
LoadSegment(Offset) (*Segment, error)
}
// SegmentWriter defines the interface of a type that is able to store
// WAL segments.
type SegmentWriter interface {
WriteSegment(*Segment) error
}