-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhandler.go
More file actions
140 lines (106 loc) · 4.09 KB
/
Copy pathhandler.go
File metadata and controls
140 lines (106 loc) · 4.09 KB
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
package rdb
import "time"
// ValueHandler is used to handle RDB objects while reading a file.
type ValueHandler interface {
// whether the handler can skip known but not yet supported types or not.
AllowPartialRead() bool
// whether the handler expects the file to end with the eof opcode, i.e,
// has no more bytes to the right of it.
RequireStrictEOF() bool
// called when a string value is read for the key.
HandleString(key, value string) error
// returned function is called for the each enty read for the key.
ListEntryHandler(key string) func(elem string) error
// called when the list is read completely, with the name and the number of entries read.
HandleListEnding(key string, entriesRead uint64)
// returned function is called for the each enty read for the key.
SetEntryHandler(key string) func(elem string) error
// returned function is called for the each enty read for the key.
ZsetEntryHandler(key string) func(elem string, score float64) error
// called when the zset is read completely, with the name and the number of entries read.
HandleZsetEnding(key string, entriesRead uint64)
// returned function is called for the each enty read for the key.
HashEntryHandler(key string) func(field, value string) error
// called when a module value is read for the key.
HandleModule(key, value string, marker ModuleMarker) error
// returned function is called for the each stream enty read for the key.
StreamEntryHandler(key string) func(entry StreamEntry) error
// returned function is called for the each stream group read for the key.
StreamGroupHandler(key string) func(group StreamConsumerGroup) error
// called when the stream entries and groups are read completely,
// with the name and the number of entries read.
HandleStreamEnding(key string, entriesRead uint64)
// returned function is called for each read hash entry with expiration info for the key.
HashWithExpEntryHandler(key string) func(field string, value string, exp time.Time) error
// called when the a function code is read
HandleLibrary(code string) error
}
// FileHandler is an extension of ValueHandler, which can handle RDB objects
// and their expiration information from RDB files.
type FileHandler interface {
ValueHandler
// called when a key expiration timestamp is read.
HandleExpireTime(key string, expireTime time.Time)
HandleLibrary(code string) error
}
// nopHandler is used to ignore the RDB objects read so that
// the file can be read while skipping the values we don't need
// to read.
type nopHandler struct {
}
func (nopHandler) AllowPartialRead() bool {
return true
}
func (nopHandler) RequireStrictEOF() bool {
return false
}
func (nopHandler) HandleString(key, value string) error {
return nil
}
func (nopHandler) ListEntryHandler(key string) func(elem string) error {
return func(elem string) error {
return nil
}
}
func (nopHandler) HandleListEnding(key string, entriesRead uint64) {
}
func (nopHandler) SetEntryHandler(key string) func(elem string) error {
return func(elem string) error {
return nil
}
}
func (nopHandler) ZsetEntryHandler(key string) func(elem string, score float64) error {
return func(elem string, score float64) error {
return nil
}
}
func (nopHandler) HandleZsetEnding(key string, entriesRead uint64) {
}
func (nopHandler) HashEntryHandler(key string) func(field, value string) error {
return func(field, value string) error {
return nil
}
}
func (nopHandler) HandleModule(key, value string, marker ModuleMarker) error {
return nil
}
func (nopHandler) StreamEntryHandler(key string) func(entry StreamEntry) error {
return func(entry StreamEntry) error {
return nil
}
}
func (nopHandler) StreamGroupHandler(key string) func(group StreamConsumerGroup) error {
return func(group StreamConsumerGroup) error {
return nil
}
}
func (nopHandler) HandleStreamEnding(key string, entriesRead uint64) {
}
func (nopHandler) HandleExpireTime(key string, expireTime time.Time) {
}
func (h nopHandler) HashWithExpEntryHandler(key string) func(field string, value string, exp time.Time) error {
return nil
}
func (nopHandler) HandleLibrary(code string) error {
return nil
}