This repository has been archived by the owner on Jun 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
table.go
62 lines (47 loc) · 1.48 KB
/
table.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
package streams
import "errors"
// ErrNotImplemented is returned when a method is not implemented.
var ErrNotImplemented = errors.New("not implemented")
// NextCursor is the next cursor.
type NextCursor struct {
Key string
Value []byte
Latest bool
}
// Iterator is the interface that wraps the basic Next method.
type Iterator interface {
// Next moves the cursor to the next key/value pair, which will then be available through the Key, Value and Latest methods.
// It returns false if the iterator is exhausted.
Next() <-chan NextCursor
}
// Table is the interface that wraps the basic Set, Delete, Setup, Error and Sink methods.
type Table interface {
// Set is setting a key/value pair.
Set(key string, value []byte) error
// Delete is deleting a key/value pair.
Delete(key string) error
// Setup is setting up the table.
Setup() error
// Error is returning the error.
Error() error
// Sink is the interface that wraps the basic Sink method.
Sink[string, []byte]
Iterator
}
type tableUnimplemented struct{}
// Setup is setting key/value pair.
func (t *tableUnimplemented) Set(key string, value []byte) error {
return ErrNotImplemented
}
// Delete is deleting a key/value pair.
func (t *tableUnimplemented) Delete(key string) error {
return ErrNotImplemented
}
// Setup is setting up the table.
func (t *tableUnimplemented) Setup() error {
return ErrNotImplemented
}
// Error is returning the error.
func (t *tableUnimplemented) Error() error {
return ErrNotImplemented
}