This repository has been archived by the owner on Sep 8, 2018. It is now read-only.
/
log.go
51 lines (45 loc) · 1.28 KB
/
log.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
package ingest
import (
"errors"
"io"
)
// Log is an abstraction for segments on an ingest node.
// A new active segment may be created and written to.
// The oldest flushed segment may be selected and read from.
type Log interface {
Create() (WriteSegment, error)
Oldest() (ReadSegment, error)
Stats() (LogStats, error)
Close() error
}
// WriteSegment is a segment that can be written to.
// It may be optionally synced to disk manually.
// When writing is complete, it may be closed and flushed.
// If it would be closed with size 0, it may be deleted instead.
type WriteSegment interface {
io.Writer
Sync() error
Close() error
Delete() error
}
// ReadSegment is a segment that can be read from.
// Once read, it may be committed and thus deleted.
// Or it may be failed, and made available for selection again.
type ReadSegment interface {
io.Reader
Commit() error
Failed() error
Size() int64
}
// ErrNoSegmentsAvailable is returned by IngestLog Oldest,
// when no segments are available for reading.
var ErrNoSegmentsAvailable = errors.New("no segments available")
// LogStats describe the current state of the ingest log.
type LogStats struct {
ActiveSegments int64
ActiveBytes int64
FlushedSegments int64
FlushedBytes int64
PendingSegments int64
PendingBytes int64
}