-
Notifications
You must be signed in to change notification settings - Fork 106
/
backend_queue.go
63 lines (56 loc) · 1.45 KB
/
backend_queue.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
package nsqd
type BackendOffset int64
type BackendQueueOffset interface {
Offset() BackendOffset
}
type BackendQueueEnd interface {
Offset() BackendOffset
TotalMsgCnt() int64
IsSame(BackendQueueEnd) bool
}
// BackendQueue represents the behavior for the secondary message
// storage system
type BackendQueue interface {
Put([]byte) error
ReadChan() chan []byte // this is expected to be an *unbuffered* channel
Close() error
Delete() error
Depth() int64
Empty() error
}
// for topic producer
type BackendQueueWriter interface {
Put([]byte) (BackendOffset, int32, int64, error)
Close() error
Delete() error
Empty() error
Flush() error
GetQueueWriteEnd() BackendQueueEnd
GetQueueReadStart() BackendQueueEnd
GetQueueReadEnd() BackendQueueEnd
RollbackWrite(BackendOffset, uint64) error
ResetWriteEnd(BackendOffset, int64) error
}
type ReadResult struct {
Offset BackendOffset
MovedSize BackendOffset
CurCnt int64
Data []byte
Err error
}
// for channel consumer
type BackendQueueReader interface {
ConfirmRead(BackendOffset, int64) error
ResetReadToConfirmed() (BackendQueueEnd, error)
SkipReadToOffset(BackendOffset, int64) (BackendQueueEnd, error)
SkipReadToEnd() (BackendQueueEnd, error)
Close() error
// left data to be read
Depth() int64
DepthSize() int64
GetQueueReadEnd() BackendQueueEnd
GetQueueConfirmed() BackendQueueEnd
Delete() error
UpdateQueueEnd(BackendQueueEnd, bool) (bool, error)
TryReadOne() (ReadResult, bool)
}