mysql_replicator 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. checksums.yaml +7 -0
  2. data/.rspec +3 -0
  3. data/.rubocop.yml +79 -0
  4. data/CHANGELOG.md +5 -0
  5. data/CODE_OF_CONDUCT.md +132 -0
  6. data/LICENSE.txt +21 -0
  7. data/README.md +115 -0
  8. data/Rakefile +12 -0
  9. data/Steepfile +22 -0
  10. data/docker-compose.yml +13 -0
  11. data/lib/mysql_replicator/binlog_client.rb +201 -0
  12. data/lib/mysql_replicator/binlogs/column_parser.rb +425 -0
  13. data/lib/mysql_replicator/binlogs/constants.rb +74 -0
  14. data/lib/mysql_replicator/binlogs/event_parser.rb +134 -0
  15. data/lib/mysql_replicator/binlogs/format_description_event_parser.rb +24 -0
  16. data/lib/mysql_replicator/binlogs/json_parser.rb +335 -0
  17. data/lib/mysql_replicator/binlogs/query_event_parser.rb +69 -0
  18. data/lib/mysql_replicator/binlogs/rotate_event_parser.rb +37 -0
  19. data/lib/mysql_replicator/binlogs/rows_event_parser.rb +161 -0
  20. data/lib/mysql_replicator/binlogs/table_map_event_parser.rb +155 -0
  21. data/lib/mysql_replicator/binlogs/xid_event_parser.rb +25 -0
  22. data/lib/mysql_replicator/connection.rb +226 -0
  23. data/lib/mysql_replicator/connections/auth.rb +303 -0
  24. data/lib/mysql_replicator/connections/handshake.rb +132 -0
  25. data/lib/mysql_replicator/connections/query.rb +322 -0
  26. data/lib/mysql_replicator/error.rb +6 -0
  27. data/lib/mysql_replicator/logger.rb +43 -0
  28. data/lib/mysql_replicator/string_io_util.rb +199 -0
  29. data/lib/mysql_replicator/string_util.rb +106 -0
  30. data/lib/mysql_replicator/version.rb +6 -0
  31. data/lib/mysql_replicator.rb +51 -0
  32. data/sig/generated/mysql_replicator/binlog_client.rbs +52 -0
  33. data/sig/generated/mysql_replicator/binlogs/column_parser.rbs +134 -0
  34. data/sig/generated/mysql_replicator/binlogs/constants.rbs +69 -0
  35. data/sig/generated/mysql_replicator/binlogs/event_parser.rbs +35 -0
  36. data/sig/generated/mysql_replicator/binlogs/format_description_event_parser.rbs +13 -0
  37. data/sig/generated/mysql_replicator/binlogs/json_parser.rbs +101 -0
  38. data/sig/generated/mysql_replicator/binlogs/query_event_parser.rbs +14 -0
  39. data/sig/generated/mysql_replicator/binlogs/rotate_event_parser.rbs +14 -0
  40. data/sig/generated/mysql_replicator/binlogs/rows_event_parser.rbs +39 -0
  41. data/sig/generated/mysql_replicator/binlogs/table_map_event_parser.rbs +31 -0
  42. data/sig/generated/mysql_replicator/binlogs/xid_event_parser.rbs +13 -0
  43. data/sig/generated/mysql_replicator/connection.rbs +103 -0
  44. data/sig/generated/mysql_replicator/connections/auth.rbs +76 -0
  45. data/sig/generated/mysql_replicator/connections/handshake.rbs +21 -0
  46. data/sig/generated/mysql_replicator/connections/query.rbs +62 -0
  47. data/sig/generated/mysql_replicator/error.rbs +6 -0
  48. data/sig/generated/mysql_replicator/logger.rbs +26 -0
  49. data/sig/generated/mysql_replicator/string_io_util.rbs +75 -0
  50. data/sig/generated/mysql_replicator/string_util.rbs +45 -0
  51. data/sig/generated/mysql_replicator/types.rbs +19 -0
  52. data/sig/generated/mysql_replicator/version.rbs +5 -0
  53. data/sig/generated/mysql_replicator.rbs +16 -0
  54. metadata +124 -0
@@ -0,0 +1,106 @@
1
+ # frozen_string_literal: true
2
+ # rbs_inline: enabled
3
+
4
+ module MysqlReplicator
5
+ class StringUtil
6
+ # @rbs payload: String | nil
7
+ # @rbs return: String
8
+ def self.read_str(payload)
9
+ if payload.nil?
10
+ raise MysqlReplicator::Error, 'payload is nil'
11
+ end
12
+
13
+ payload
14
+ end
15
+
16
+ # @rbs payload: String | nil
17
+ # @rbs return: Integer
18
+ def self.read_uint8(payload)
19
+ if payload.nil?
20
+ raise MysqlReplicator::Error, 'payload is nil'
21
+ end
22
+
23
+ payload.unpack1('C').to_i
24
+ end
25
+
26
+ # @rbs payload: String | nil
27
+ # @rbs return: Integer
28
+ def self.read_uint16(payload)
29
+ if payload.nil?
30
+ raise MysqlReplicator::Error, 'payload is nil'
31
+ end
32
+
33
+ payload.unpack1('v').to_i
34
+ end
35
+
36
+ # @rbs payload: String | nil
37
+ # @rbs return: Integer
38
+ def self.read_int16(payload)
39
+ if payload.nil?
40
+ raise MysqlReplicator::Error, 'payload is nil'
41
+ end
42
+
43
+ payload.unpack1('s<').to_i
44
+ end
45
+
46
+ # @rbs payload: String | nil
47
+ # @rbs return: Integer
48
+ def self.read_uint32(payload)
49
+ if payload.nil?
50
+ raise MysqlReplicator::Error, 'payload is nil'
51
+ end
52
+
53
+ payload.unpack1('V').to_i
54
+ end
55
+
56
+ # @rbs payload: String | nil
57
+ # @rbs return: Integer
58
+ def self.read_int32(payload)
59
+ if payload.nil?
60
+ raise MysqlReplicator::Error, 'payload is nil'
61
+ end
62
+
63
+ payload.unpack1('l<').to_i
64
+ end
65
+
66
+ # @rbs payload: String | nil
67
+ # @rbs return: Integer
68
+ def self.read_uint64(payload)
69
+ if payload.nil?
70
+ raise MysqlReplicator::Error, 'payload is nil'
71
+ end
72
+
73
+ payload.unpack1('Q<').to_i
74
+ end
75
+
76
+ # @rbs paylaod: String | nil
77
+ # @rbs return: Integer
78
+ def self.read_int64(payload)
79
+ if payload.nil?
80
+ raise MysqlReplicator::Error, 'payload is nil'
81
+ end
82
+
83
+ payload.unpack1('q<').to_i
84
+ end
85
+
86
+ # @rbs paylaod: String | nil
87
+ # @rbs return: Float
88
+ def self.read_double64(payload)
89
+ if payload.nil?
90
+ raise MysqlReplicator::Error, 'payload is nil'
91
+ end
92
+
93
+ payload.unpack1('E').to_f
94
+ end
95
+
96
+ # @rbs payload: String | nil
97
+ # @rbs return: Array[Integer]
98
+ def self.read_array_from_int8(payload)
99
+ if payload.nil?
100
+ raise MysqlReplicator::Error, 'payload is nil'
101
+ end
102
+
103
+ payload.unpack('C*').map(&:to_i)
104
+ end
105
+ end
106
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+ # rbs_inline: enabled
3
+
4
+ module MysqlReplicator
5
+ VERSION = '0.1.0' #: String
6
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+ # rbs_inline: enabled
3
+
4
+ require_relative 'mysql_replicator/binlog_client'
5
+ require_relative 'mysql_replicator/binlogs/column_parser'
6
+ require_relative 'mysql_replicator/binlogs/constants'
7
+ require_relative 'mysql_replicator/binlogs/event_parser'
8
+ require_relative 'mysql_replicator/binlogs/format_description_event_parser'
9
+ require_relative 'mysql_replicator/binlogs/json_parser'
10
+ require_relative 'mysql_replicator/binlogs/query_event_parser'
11
+ require_relative 'mysql_replicator/binlogs/rotate_event_parser'
12
+ require_relative 'mysql_replicator/binlogs/rows_event_parser'
13
+ require_relative 'mysql_replicator/binlogs/table_map_event_parser'
14
+ require_relative 'mysql_replicator/binlogs/xid_event_parser'
15
+ require_relative 'mysql_replicator/connection'
16
+ require_relative 'mysql_replicator/connections/auth'
17
+ require_relative 'mysql_replicator/connections/handshake'
18
+ require_relative 'mysql_replicator/connections/query'
19
+ require_relative 'mysql_replicator/error'
20
+ require_relative 'mysql_replicator/logger'
21
+ require_relative 'mysql_replicator/string_util'
22
+ require_relative 'mysql_replicator/string_io_util'
23
+ require_relative 'mysql_replicator/version'
24
+
25
+ module MysqlReplicator
26
+ # @rbs host: String
27
+ # @rbs port: Integer
28
+ # @rbs user: String
29
+ # @rbs password: String
30
+ # @rbs database: String
31
+ # @rbs &block: { (MysqlReplicator::Binlogs::EventParser::binlogEvent) -> untyped | nil }?
32
+ # @rbs return: void
33
+ def self.run(host: '127.0.0.1', port: 3306, user: 'root', password: 'root', database: '', &block)
34
+ conn = MysqlReplicator::Connection.new(
35
+ host: host,
36
+ port: port,
37
+ user: user,
38
+ password: password,
39
+ database: database
40
+ )
41
+ client = MysqlReplicator::BinlogClient.new(conn)
42
+ client.on(&block) if block_given?
43
+ client.start_replication
44
+ end
45
+
46
+ # @rbs custom_logger: ::Logger
47
+ # @rbs return: void
48
+ def self.logger=(custom_logger)
49
+ MysqlReplicator::Logger.logger = custom_logger
50
+ end
51
+ end
@@ -0,0 +1,52 @@
1
+ # Generated from lib/mysql_replicator/binlog_client.rb with RBS::Inline
2
+
3
+ module MysqlReplicator
4
+ # Binlog handler using MySQL Replication Protocol
5
+ class BinlogClient
6
+ @connection: MysqlReplicator::Connection
7
+
8
+ @server_id: Integer
9
+
10
+ @checksum_type: String?
11
+
12
+ @event_listener: ^(MysqlReplicator::Binlogs::EventParser::binlogEvent) -> untyped | nil
13
+
14
+ # @rbs! attr_reader connection: MysqlReplicator::Connection
15
+ attr_reader connection: untyped
16
+
17
+ # @rbs connection: MysqlReplicator::Connection
18
+ # @rbs server_id: Integer
19
+ # @rbs return void
20
+ def initialize: (MysqlReplicator::Connection connection, ?Integer server_id) -> void
21
+
22
+ # @rbs &block: { (MysqlReplicator::Binlogs::EventParser::binlogEvent) -> untyped | nil }
23
+ # @rbs return: void
24
+ def on: () ?{ (?) -> untyped } -> void
25
+
26
+ # @rbs return: void
27
+ def start_replication: () -> void
28
+
29
+ # @rbs return: void
30
+ def stop_replication: () -> void
31
+
32
+ # @rbs return: { file: String, position: Integer }
33
+ def master_status: () -> { file: String, position: Integer }
34
+
35
+ # @rbs return: void
36
+ def register_as_slave: () -> void
37
+
38
+ # @rbs return: void
39
+ def unregister_as_slave: () -> void
40
+
41
+ # @rbs return: void
42
+ def configure_binlog_checksum: () -> void
43
+
44
+ # @rbs binlog_file: String
45
+ # @rbs binlog_position: Integer
46
+ # @rbs return: void
47
+ def start_binlog_dump: (String binlog_file, Integer binlog_position) -> void
48
+
49
+ # @rbs return: void
50
+ def handle_binlog_events: () -> void
51
+ end
52
+ end
@@ -0,0 +1,134 @@
1
+ # Generated from lib/mysql_replicator/binlogs/column_parser.rb with RBS::Inline
2
+
3
+ module MysqlReplicator
4
+ module Binlogs
5
+ class ColumnParser
6
+ # @rbs io: StringIO
7
+ # @rbs column_def: MysqlReplicator::Binlogs::TableMapEventParser::columnData
8
+ def self.parse: (StringIO io, MysqlReplicator::Binlogs::TableMapEventParser::columnData column_def) -> untyped
9
+
10
+ # @rbs io: StringIO
11
+ # @rbs return: Integer
12
+ def self.parse_tinyint: (StringIO io) -> Integer
13
+
14
+ # @rbs io: StringIO
15
+ # @rbs return: Integer
16
+ def self.parse_smallint: (StringIO io) -> Integer
17
+
18
+ # @rbs io: StringIO
19
+ # @rbs return: Integer
20
+ def self.parse_mediumint: (StringIO io) -> Integer
21
+
22
+ # @rbs io: StringIO
23
+ # @rbs return: Integer
24
+ def self.parse_int: (StringIO io) -> Integer
25
+
26
+ # @rbs io: StringIO
27
+ # @rbs return: Integer
28
+ def self.parse_bigint: (StringIO io) -> Integer
29
+
30
+ # @rbs io: StringIO
31
+ # @rbs return: Float
32
+ def self.parse_float: (StringIO io) -> Float
33
+
34
+ # @rbs io: StringIO
35
+ # @rbs return: Float
36
+ def self.parse_double: (StringIO io) -> Float
37
+
38
+ # This is sensitive...
39
+ #
40
+ # @rbs io: StringIO
41
+ # @rbs column_def: MysqlReplicator::Binlogs::TableMapEventParser::columnData
42
+ # @rbs return: BigDecimal
43
+ def self.parse_decimal: (StringIO io, MysqlReplicator::Binlogs::TableMapEventParser::columnData column_def) -> BigDecimal
44
+
45
+ # @rbs io: StringIO
46
+ # @return: String
47
+ def self.parse_datetime: (StringIO io) -> untyped
48
+
49
+ # @rbs io: StringIO
50
+ # @return: String
51
+ def self.parse_date: (StringIO io) -> untyped
52
+
53
+ # @rbs io: StringIO
54
+ # @return: String
55
+ def self.parse_time: (StringIO io) -> untyped
56
+
57
+ # @rbs io: StringIO
58
+ # @return: Integer
59
+ def self.parse_timestamp: (StringIO io) -> untyped
60
+
61
+ # @rbs io: StringIO
62
+ # @rbs column_def: MysqlReplicator::Binlogs::TableMapEventParser::columnData
63
+ # @rbs return: String
64
+ def self.parse_varchar: (StringIO io, MysqlReplicator::Binlogs::TableMapEventParser::columnData column_def) -> String
65
+
66
+ # @rbs column_def: MysqlReplicator::Binlogs::TableMapEventParser::columnData
67
+ # @rbs return: String
68
+ def self.parse_char: (untyped io, MysqlReplicator::Binlogs::TableMapEventParser::columnData column_def) -> String
69
+
70
+ # @rbs io: StringIO
71
+ # @rbs column_def: MysqlReplicator::Binlogs::TableMapEventParser::columnData
72
+ # @rbs return: String
73
+ def self.parse_tinytext: (StringIO io, MysqlReplicator::Binlogs::TableMapEventParser::columnData column_def) -> String
74
+
75
+ # @rbs io: StringIO
76
+ # @rbs column_def: MysqlReplicator::Binlogs::TableMapEventParser::columnData
77
+ # @rbs return: String
78
+ def self.parse_text: (StringIO io, MysqlReplicator::Binlogs::TableMapEventParser::columnData column_def) -> String
79
+
80
+ # @rbs io: StringIO
81
+ # @rbs column_def: MysqlReplicator::Binlogs::TableMapEventParser::columnData
82
+ # @rbs return: String
83
+ def self.parse_mediumtext: (StringIO io, MysqlReplicator::Binlogs::TableMapEventParser::columnData column_def) -> String
84
+
85
+ # @rbs io: StringIO
86
+ # @rbs column_def: MysqlReplicator::Binlogs::TableMapEventParser::columnData
87
+ # @rbs return: String
88
+ def self.parse_longtext: (StringIO io, MysqlReplicator::Binlogs::TableMapEventParser::columnData column_def) -> String
89
+
90
+ # @rbs io: StringIO
91
+ # @rbs return: String
92
+ def self.parse_tinyblob: (StringIO io) -> String
93
+
94
+ # @rbs io: StringIO
95
+ # @rbs return: String
96
+ def self.parse_blob: (StringIO io) -> String
97
+
98
+ # @rbs io: StringIO
99
+ # @rbs return: String
100
+ def self.parse_mediumblob: (StringIO io) -> String
101
+
102
+ # @rbs io: StringIO
103
+ # @rbs return: String
104
+ def self.parse_longblob: (StringIO io) -> String
105
+
106
+ # @rbs io: StringIO
107
+ # @rbs return: String
108
+ def self.parse_varbinary: (StringIO io, untyped column_def) -> String
109
+
110
+ # @rbs io: StringIO
111
+ # @rbs column_def: MysqlReplicator::Binlogs::TableMapEventParser::columnData
112
+ # @rbs return: String
113
+ def self.parse_binary: (StringIO io, MysqlReplicator::Binlogs::TableMapEventParser::columnData column_def) -> String
114
+
115
+ # @rbs io: StringIO
116
+ # @return Hash[Symbol, String | Integer | bool | nil]
117
+ def self.parse_json: (StringIO io) -> untyped
118
+
119
+ # @rbs io: StringIO
120
+ # @rbs column_def: MysqlReplicator::Binlogs::TableMapEventParser::columnData
121
+ # @rbs return: String | Integer
122
+ def self.parse_enum: (StringIO io, MysqlReplicator::Binlogs::TableMapEventParser::columnData column_def) -> (String | Integer)
123
+
124
+ # @rbs digits: Integer
125
+ # @rbs return: Integer
126
+ def self.decimal_storage_bytes: (Integer digits) -> Integer
127
+
128
+ # @rbs bytes: Array[Integer]
129
+ # @rbs digits: Integer
130
+ # @rbs return: Integer
131
+ def self.parse_decimal_digits: (Array[Integer] bytes, Integer digits) -> Integer
132
+ end
133
+ end
134
+ end
@@ -0,0 +1,69 @@
1
+ # Generated from lib/mysql_replicator/binlogs/constants.rb with RBS::Inline
2
+
3
+ module MysqlReplicator
4
+ module Binlogs
5
+ # MySQL Field Types contants
6
+ module FieldTypes
7
+ TINY_INT: String
8
+
9
+ SMALL_INT: String
10
+
11
+ MEDIUM_INT: String
12
+
13
+ INT: String
14
+
15
+ BIG_INT: String
16
+
17
+ FLOAT: String
18
+
19
+ DOUBLE: String
20
+
21
+ DECIMAL: String
22
+
23
+ DATETIME: String
24
+
25
+ DATE: String
26
+
27
+ TIME: String
28
+
29
+ TIMESTAMP: String
30
+
31
+ CHAR: String
32
+
33
+ VARCHAR: String
34
+
35
+ TINY_TEXT: String
36
+
37
+ MEDIUM_TEXT: String
38
+
39
+ TEXT: String
40
+
41
+ LONG_TEXT: String
42
+
43
+ TINY_BLOB: String
44
+
45
+ MEDIUM_BLOB: String
46
+
47
+ BLOB: String
48
+
49
+ LONG_BLOB: String
50
+
51
+ BINARY: String
52
+
53
+ VAR_BINARY: String
54
+
55
+ JSON: String
56
+
57
+ ENUM: String
58
+
59
+ UNKNOWN: String
60
+
61
+ # Mapping from INFORMATION_SCHEMA DATA_TYPE to MySQL Field Type
62
+ DATA_TYPE_MAP: Hash[String, String]
63
+
64
+ # @rbs data_type: String
65
+ # @rbs return: String
66
+ def self.code_for: (String data_type) -> String
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,35 @@
1
+ # Generated from lib/mysql_replicator/binlogs/event_parser.rb with RBS::Inline
2
+
3
+ module MysqlReplicator
4
+ module Binlogs
5
+ class EventParser
6
+ type execution = MysqlReplicator::Binlogs::FormatDescriptionEventParser::execution | MysqlReplicator::Binlogs::QueryEventParser::execution | MysqlReplicator::Binlogs::RotateEventParser::execution | MysqlReplicator::Binlogs::RowsEventParser::execution | MysqlReplicator::Binlogs::TableMapEventParser::execution | MysqlReplicator::Binlogs::XidEventParser::execution | Hash[untyped, untyped]
7
+
8
+ type binlogEvent = { timestamp: Time, event_type: Symbol, server_id: Integer, length: Integer, next_position: Integer, flags: Integer, execution: execution }
9
+
10
+ @stored_table_map: Hash[Integer, MysqlReplicator::Binlogs::TableMapEventParser::execution]
11
+
12
+ # @rbs return: void
13
+ def initialize: () -> void
14
+
15
+ # @rbs payload: String
16
+ # @rbs connection: MysqlReplicator::Connection
17
+ # @rbs checksum_enabled: bool
18
+ # @rbs return: binlogEvent
19
+ def execute: (String payload, MysqlReplicator::Connection connection, bool checksum_enabled) -> binlogEvent
20
+
21
+ # Basic event type identification
22
+ #
23
+ # @rbs event_type: Integer
24
+ # @rbs return: Symbol
25
+ def readable_event_type: (Integer event_type) -> Symbol
26
+
27
+ # @rbs event_type: Symbol
28
+ # @rbs payload: String
29
+ # @rbs connection: MysqlReplicator::Connection
30
+ # @rbs checksum_enabled: bool
31
+ # @rbs return: execution
32
+ def parse_execution_data: (Symbol event_type, String payload, MysqlReplicator::Connection connection, bool checksum_enabled) -> execution
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,13 @@
1
+ # Generated from lib/mysql_replicator/binlogs/format_description_event_parser.rb with RBS::Inline
2
+
3
+ module MysqlReplicator
4
+ module Binlogs
5
+ class FormatDescriptionEventParser
6
+ type execution = { binlog_version: Integer, server_version: String }
7
+
8
+ # @rbs payload: String
9
+ # @rbs return: execution
10
+ def self.parse: (String payload) -> execution
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,101 @@
1
+ # Generated from lib/mysql_replicator/binlogs/json_parser.rb with RBS::Inline
2
+
3
+ module MysqlReplicator
4
+ module Binlogs
5
+ class JsonParser
6
+ type jsonValue = String | Integer | Float | bool | nil
7
+
8
+ type json = Hash[Symbol, json] | Array[json] | jsonValue
9
+
10
+ JSONB_TYPE_SMALL_OBJECT: Integer
11
+
12
+ JSONB_TYPE_LARGE_OBJECT: Integer
13
+
14
+ JSONB_TYPE_SMALL_ARRAY: Integer
15
+
16
+ JSONB_TYPE_LARGE_ARRAY: Integer
17
+
18
+ JSONB_TYPE_LITERAL: Integer
19
+
20
+ JSONB_TYPE_INT16: Integer
21
+
22
+ JSONB_TYPE_UINT16: Integer
23
+
24
+ JSONB_TYPE_INT32: Integer
25
+
26
+ JSONB_TYPE_UINT32: Integer
27
+
28
+ JSONB_TYPE_INT64: Integer
29
+
30
+ JSONB_TYPE_UINT64: Integer
31
+
32
+ JSONB_TYPE_DOUBLE: Integer
33
+
34
+ JSONB_TYPE_STRING: Integer
35
+
36
+ JSONB_TYPE_OPAQUE: Integer
37
+
38
+ JSONB_NULL: Integer
39
+
40
+ JSONB_TRUE: Integer
41
+
42
+ JSONB_FALSE: Integer
43
+
44
+ # @rbs payload: String | nil
45
+ # @rbs return: json
46
+ def self.parse: (String | nil payload) -> json
47
+
48
+ # @rbs type: Integer
49
+ # @rbs data: String
50
+ # @rbs pos: Integer
51
+ # @rbs return: json
52
+ def self.parse_value: (Integer type, String data, Integer pos) -> json
53
+
54
+ # @rbs type: Integer
55
+ # @rbs data: String
56
+ # @rbs offset: Integer
57
+ # @rbs base_offset: Integer
58
+ # @rbs return: json
59
+ def self.parse_value_at_offset: (Integer type, String data, Integer offset, Integer base_offset) -> json
60
+
61
+ # SMALL: under 65535 elements, and 2byte offsets
62
+ # LARGE: 65535 elements or more, and 4byte offsets
63
+ #
64
+ # @rbs data: String
65
+ # @rbs pos: Integer
66
+ # @rbs small: bool
67
+ # @rbs return: Hash[Symbol, json]
68
+ def self.parse_object: (String data, Integer pos, small: bool) -> Hash[Symbol, json]
69
+
70
+ # @rbs data: String
71
+ # @rbs pos: Integer
72
+ # @rbs small: bool
73
+ # @rbs return: Array[json]
74
+ def self.parse_array: (String data, Integer pos, small: bool) -> Array[json]
75
+
76
+ # @rbs literal_type: Integer
77
+ # @rbs return: bool | nil
78
+ def self.parse_literal: (Integer literal_type) -> (bool | nil)
79
+
80
+ # @rbs data: String
81
+ # @rbs pos: Integer
82
+ # @rbs return: String
83
+ def self.parse_string: (String data, Integer pos) -> String
84
+
85
+ # @rbs type: Integer
86
+ # @rbs small: bool
87
+ # @rbs return: bool
88
+ def self.inlined_type?: (Integer type, bool small) -> bool
89
+
90
+ # @rbs data: String
91
+ # @rbs pos: Integer
92
+ # @rbs return: Integer | bool | nil
93
+ def self.read_inlined_value: (String data, Integer pos, untyped type) -> (Integer | bool | nil)
94
+
95
+ # @rbs data: String
96
+ # @rbs pos: Integer
97
+ # @rbs return: [Integer, Integer]
98
+ def self.read_variable_length: (String data, Integer pos) -> [ Integer, Integer ]
99
+ end
100
+ end
101
+ end
@@ -0,0 +1,14 @@
1
+ # Generated from lib/mysql_replicator/binlogs/query_event_parser.rb with RBS::Inline
2
+
3
+ module MysqlReplicator
4
+ module Binlogs
5
+ class QueryEventParser
6
+ type execution = { thread_id: Integer, exec_time: Integer, error_code: Integer, database: String | nil, sql: String | nil }
7
+
8
+ # @rbs payload: String
9
+ # @rbs checksum_enabled: bool
10
+ # @rbs return: execution
11
+ def self.parse: (String payload, bool checksum_enabled) -> execution
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ # Generated from lib/mysql_replicator/binlogs/rotate_event_parser.rb with RBS::Inline
2
+
3
+ module MysqlReplicator
4
+ module Binlogs
5
+ class RotateEventParser
6
+ type execution = { position: Integer, filename: String }
7
+
8
+ # @rbs payload: String
9
+ # @rbs checksum_enabled: bool
10
+ # @rbs return: execution
11
+ def self.parse: (String payload, ?bool checksum_enabled) -> execution
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,39 @@
1
+ # Generated from lib/mysql_replicator/binlogs/rows_event_parser.rb with RBS::Inline
2
+
3
+ module MysqlReplicator
4
+ module Binlogs
5
+ class RowsEventParser
6
+ type rowData = { ordinal_position: Integer, data_type: String, column_name: String, value: String | Integer | bool | nil, primary_key: bool }
7
+
8
+ type execution = { table_id: Integer, flags: Integer, extra_data_length: Integer, column_count: Integer, rows: Array[rowData] }
9
+
10
+ # @rbs event_type: :WRITE_ROWS | :UPDATE_ROWS | :DELETE_ROWS
11
+ # @rbs payload: String
12
+ # @rbs checksum_enabled bool
13
+ # @rbs table_map: Hash[Integer, MysqlReplicator::Binlogs::TableMapEventParser::execution]
14
+ # @rbs return: execution
15
+ def self.parse: (:WRITE_ROWS | :UPDATE_ROWS | :DELETE_ROWS event_type, String payload, bool checksum_enabled, Hash[Integer, MysqlReplicator::Binlogs::TableMapEventParser::execution] table_map) -> execution
16
+
17
+ # @rbs io: StringIO
18
+ # @rbs column_count: Integer
19
+ # @rbs columns_present_bitmap: Array[Integer]
20
+ # @rbs table_def: MysqlReplicator::Binlogs::TableMapEventParser::execution
21
+ # @rbs return: Array[rowData]
22
+ def self.parse_row: (StringIO io, Integer column_count, Array[Integer] columns_present_bitmap, MysqlReplicator::Binlogs::TableMapEventParser::execution table_def) -> Array[rowData]
23
+
24
+ # @rbs io: StringIO
25
+ # @rbs return: Integer
26
+ def self.read_packed_integer: (StringIO io) -> Integer
27
+
28
+ # @rbs bitmap: Array[Integer]
29
+ # @rbs index: Integer
30
+ # @rbs return: bool
31
+ def self.bit_set?: (Array[Integer] bitmap, Integer index) -> bool
32
+
33
+ # @rbs bitmap: Array[Integer]
34
+ # @rbs max_bits: Integer
35
+ # @rbs return: Integer
36
+ def self.count_bits: (Array[Integer] bitmap, Integer max_bits) -> Integer
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,31 @@
1
+ # Generated from lib/mysql_replicator/binlogs/table_map_event_parser.rb with RBS::Inline
2
+
3
+ module MysqlReplicator
4
+ module Binlogs
5
+ class TableMapEventParser
6
+ type columnData = { ordinal_position: Integer, data_type: String, column_name: String, column_type: String, enum_values: Array[String] | nil, nullable: bool, column_default: String | nil, numeric_precision: Integer, numeric_scale: Integer, character_maximum_length: Integer, character_set_name: String, collation_name: String, primary_key: bool }
7
+
8
+ type execution = { database: String | nil, table: String | nil, table_id: Integer, columns: Array[columnData], flags: Integer }
9
+
10
+ # @rbs payload: String
11
+ # @rbs connection: MysqlReplicator::Connection
12
+ # @rbs return: execution
13
+ def self.parse: (String payload, MysqlReplicator::Connection connection) -> execution
14
+
15
+ # @rbs bytes: Array[Integer]
16
+ # @rbs return: Integer
17
+ def self.to_little_endian: (Array[Integer] bytes) -> Integer
18
+
19
+ # @rbs connection: MysqlReplicator::Connection
20
+ # @rbs database: String
21
+ # @rbs table: String
22
+ # @rbs return: Array[columnData]
23
+ def self.get_table_columns: (MysqlReplicator::Connection connection, String database, String table) -> Array[columnData]
24
+
25
+ # @rbs data_type: String
26
+ # @rbs column_type: String
27
+ # @rbs return: Array[String] | nil
28
+ def self.extract_enum_from_column_type: (String data_type, String column_type) -> (Array[String] | nil)
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,13 @@
1
+ # Generated from lib/mysql_replicator/binlogs/xid_event_parser.rb with RBS::Inline
2
+
3
+ module MysqlReplicator
4
+ module Binlogs
5
+ class XidEventParser
6
+ type execution = { xid: Integer }
7
+
8
+ # @rbs payload: String
9
+ # @rbs return: execution
10
+ def self.parse: (String payload) -> execution
11
+ end
12
+ end
13
+ end