forked from go-mysql-org/go-mysql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeneric_event.go
166 lines (133 loc) · 3.12 KB
/
generic_event.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
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
package replication
import (
"encoding/hex"
"fmt"
"io"
)
// we don't parse all event, so some we will use GenericEvent instead
type GenericEvent struct {
Data []byte
}
func (e *GenericEvent) Dump(w io.Writer) {
fmt.Fprintf(w, "Event data: \n%s", hex.Dump(e.Data))
fmt.Fprintln(w)
}
func (e *GenericEvent) Decode(data []byte) error {
e.Data = data
return nil
}
//below events are generic events, maybe later I will consider handle some.
// type StartEventV3 struct {
// Version uint16
// ServerVersion [50]byte
// CreateTimestamp uint32
// }
// type StopEvent struct{}
// type LoadEvent struct {
// SlaveProxyID uint32
// ExecTime uint32
// SkipLines uint32
// TableNameLen uint8
// SchemaLen uint8
// NumFileds uint32
// FieldTerm uint8
// EnclosedBy uint8
// LineTerm uint8
// LineStart uint8
// EscapedBy uint8
// OptFlags uint8
// EmptyFlags uint8
// //len = 1 * NumFields
// FieldNameLengths []byte
// //len = sum(FieldNameLengths) + NumFields
// //array of nul-terminated strings
// FieldNames []byte
// //len = TableNameLen + 1, nul-terminated string
// TableName []byte
// //len = SchemaLen + 1, nul-terminated string
// SchemaName []byte
// //string.NUL
// FileName []byte
// }
// type NewLoadEvent struct {
// SlaveProxyID uint32
// ExecTime uint32
// SkipLines uint32
// TableNameLen uint8
// SchemaLen uint8
// NumFields uint32
// FieldTermLen uint8
// FieldTerm []byte
// EnclosedByLen uint8
// EnclosedBy []byte
// LineTermLen uint8
// LineTerm []byte
// LineStartLen uint8
// LineStart []byte
// EscapedByLen uint8
// EscapedBy []byte
// OptFlags uint8
// //len = 1 * NumFields
// FieldNameLengths []byte
// //len = sum(FieldNameLengths) + NumFields
// //array of nul-terminated strings
// FieldNames []byte
// //len = TableNameLen, nul-terminated string
// TableName []byte
// //len = SchemaLen, nul-terminated string
// SchemaName []byte
// //string.EOF
// FileName []byte
// }
// type CreateFileEvent struct {
// FileID uint32
// BlockData []byte
// }
// type AppendBlockEvent struct {
// FileID uint32
// BlockData []byte
// }
// type ExecLoadEvent struct {
// FileID uint32
// }
// type BeginLoadQueryEvent struct {
// FileID uint32
// BlockData []byte
// }
// type ExecuteLoadQueryEvent struct {
// SlaveProxyID uint32
// ExecutionTime uint32
// SchemaLength uint8
// ErrorCode uint16
// StatusVarsLength uint16
// FileID uint32
// StartPos uint32
// EndPos uint32
// DupHandlingFlags uint8
// }
// type DeleteFileEvent struct {
// FileID uint32
// }
// type RandEvent struct {
// Seed1 uint64
// Seed2 uint64
// }
// type UserVarEvent struct {
// NameLength uint32
// Name []byte
// IsNull uint8
// //if not is null
// Type uint8
// Charset uint32
// ValueLength uint32
// Value []byte
// //if more data
// Flags uint8
// }
// type IncidentEvent struct {
// Type uint16
// MessageLength uint8
// Message []byte
// }
// type HeartbeatEvent struct {
// }