generic_event.go 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. package replication
  2. import (
  3. "encoding/hex"
  4. "fmt"
  5. "io"
  6. )
  7. // we don't parse all event, so some we will use GenericEvent instead
  8. type GenericEvent struct {
  9. Data []byte
  10. }
  11. func (e *GenericEvent) Dump(w io.Writer) {
  12. fmt.Fprintf(w, "Event data: \n%s", hex.Dump(e.Data))
  13. fmt.Fprintln(w)
  14. }
  15. func (e *GenericEvent) Decode(data []byte) error {
  16. e.Data = data
  17. return nil
  18. }
  19. //below events are generic events, maybe later I will consider handle some.
  20. // type StartEventV3 struct {
  21. // Version uint16
  22. // ServerVersion [50]byte
  23. // CreateTimestamp uint32
  24. // }
  25. // type StopEvent struct{}
  26. // type LoadEvent struct {
  27. // SlaveProxyID uint32
  28. // ExecTime uint32
  29. // SkipLines uint32
  30. // TableNameLen uint8
  31. // SchemaLen uint8
  32. // NumFileds uint32
  33. // FieldTerm uint8
  34. // EnclosedBy uint8
  35. // LineTerm uint8
  36. // LineStart uint8
  37. // EscapedBy uint8
  38. // OptFlags uint8
  39. // EmptyFlags uint8
  40. // //len = 1 * NumFields
  41. // FieldNameLengths []byte
  42. // //len = sum(FieldNameLengths) + NumFields
  43. // //array of nul-terminated strings
  44. // FieldNames []byte
  45. // //len = TableNameLen + 1, nul-terminated string
  46. // TableName []byte
  47. // //len = SchemaLen + 1, nul-terminated string
  48. // SchemaName []byte
  49. // //string.NUL
  50. // FileName []byte
  51. // }
  52. // type NewLoadEvent struct {
  53. // SlaveProxyID uint32
  54. // ExecTime uint32
  55. // SkipLines uint32
  56. // TableNameLen uint8
  57. // SchemaLen uint8
  58. // NumFields uint32
  59. // FieldTermLen uint8
  60. // FieldTerm []byte
  61. // EnclosedByLen uint8
  62. // EnclosedBy []byte
  63. // LineTermLen uint8
  64. // LineTerm []byte
  65. // LineStartLen uint8
  66. // LineStart []byte
  67. // EscapedByLen uint8
  68. // EscapedBy []byte
  69. // OptFlags uint8
  70. // //len = 1 * NumFields
  71. // FieldNameLengths []byte
  72. // //len = sum(FieldNameLengths) + NumFields
  73. // //array of nul-terminated strings
  74. // FieldNames []byte
  75. // //len = TableNameLen, nul-terminated string
  76. // TableName []byte
  77. // //len = SchemaLen, nul-terminated string
  78. // SchemaName []byte
  79. // //string.EOF
  80. // FileName []byte
  81. // }
  82. // type CreateFileEvent struct {
  83. // FileID uint32
  84. // BlockData []byte
  85. // }
  86. // type AppendBlockEvent struct {
  87. // FileID uint32
  88. // BlockData []byte
  89. // }
  90. // type ExecLoadEvent struct {
  91. // FileID uint32
  92. // }
  93. // type BeginLoadQueryEvent struct {
  94. // FileID uint32
  95. // BlockData []byte
  96. // }
  97. // type ExecuteLoadQueryEvent struct {
  98. // SlaveProxyID uint32
  99. // ExecutionTime uint32
  100. // SchemaLength uint8
  101. // ErrorCode uint16
  102. // StatusVarsLength uint16
  103. // FileID uint32
  104. // StartPos uint32
  105. // EndPos uint32
  106. // DupHandlingFlags uint8
  107. // }
  108. // type DeleteFileEvent struct {
  109. // FileID uint32
  110. // }
  111. // type RandEvent struct {
  112. // Seed1 uint64
  113. // Seed2 uint64
  114. // }
  115. // type UserVarEvent struct {
  116. // NameLength uint32
  117. // Name []byte
  118. // IsNull uint8
  119. // //if not is null
  120. // Type uint8
  121. // Charset uint32
  122. // ValueLength uint32
  123. // Value []byte
  124. // //if more data
  125. // Flags uint8
  126. // }
  127. // type IncidentEvent struct {
  128. // Type uint16
  129. // MessageLength uint8
  130. // Message []byte
  131. // }
  132. // type HeartbeatEvent struct {
  133. // }