{"id":19785168,"url":"https://github.com/brokercap/bristol","last_synced_at":"2025-04-30T22:32:38.823Z","repository":{"id":93182648,"uuid":"182813049","full_name":"brokercap/Bristol","owner":"brokercap","description":"模拟 MySQL 从库,实时解析 MySQL Binlog 的简单易用的库","archived":false,"fork":false,"pushed_at":"2020-01-18T03:24:25.000Z","size":1321,"stargazers_count":24,"open_issues_count":1,"forks_count":16,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-06T05:51:15.663Z","etag":null,"topics":["go","go-binlog","gobinlog","golang","gomysql"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/brokercap.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-04-22T15:13:49.000Z","updated_at":"2024-10-24T04:10:24.000Z","dependencies_parsed_at":null,"dependency_job_id":"f2c2e11a-ea0a-41c5-8d33-5ac80f6c763c","html_url":"https://github.com/brokercap/Bristol","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brokercap%2FBristol","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brokercap%2FBristol/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brokercap%2FBristol/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brokercap%2FBristol/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brokercap","download_url":"https://codeload.github.com/brokercap/Bristol/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251791958,"owners_count":21644493,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","go-binlog","gobinlog","golang","gomysql"],"created_at":"2024-11-12T06:13:50.174Z","updated_at":"2025-04-30T22:32:37.998Z","avatar_url":"https://github.com/brokercap.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Bristol ---- 模拟MySQL从库连接,监听MySQL binlog变更并解析\r\n\r\n#### DDL 支持说明\r\n\r\n当前只支持字段在表结构末尾追加新字段，如果配置的二进制位点是在DDL 之前的位点，会出现数据和字段对应不上\r\n数据类型修改之后，如果配置的二进制位点是在DDL 之前的位点，可能会出现数据出错\r\n\r\n#### 类型转换\r\n\r\n从Binlog解析出来的数据,在转成 map[string]interface{} 的数据格式的时候\r\nMySQL里的存储类型对应Golang里的数据类型不一样\r\n括号里的代表是Golang里的数据类型\r\n\r\n\r\n- [x] - TINYINT ( int8 | unit8 )\r\n- [x] - SMALLINT ( int16 | unit16 )\r\n- [x] - MEDIUMINT ( int32 | uint32 )\r\n- [x] - INT ( int32 | uint32 )\r\n- [x] - BIGINT ( int64 | uint64 )\r\n- [x] - FLOAT ( float32 )\r\n- [x] - DOUBLE ( float64 )\r\n- [x] - REAL ( float64 )\r\n- [x] - DECIMAL , NUMERIC( 返回string类型 )\r\n- [x] - DATE , TIME , YEAR , DATETIME , TIMESTAMP   ( string )\r\n- [x] - CHAR , VARCHAR ( string )\r\n- [x] - TEXT , TINYTEXT , MEDIUMINTTEXT , - LONGTEXT ( string )\r\n- [x] - BLOB, TINYBLOB , MEDIUMINTBLOB , LONGBLOB ( string )\r\n- [x] - ENUM ( string )\r\n- [x] - SET ( []string )\r\n- [x] - BIT ( int64 )\r\n\r\n#### 使用案例\r\n`````go\r\n\r\n\tfilename := \"mysql-bin.000071\"\r\n\r\n\tvar position uint32 = 203785789\r\n\tvar DBsource = \"root:root123@tcp(127.0.0.1:3306)/test\"\r\n\r\n\treslut := make(chan error, 1)\r\n\tm := make(map[string]uint8, 0)\r\n\tm[\"bifrost_test\"] = 1\r\n\tm[\"mysql\"] = 1\r\n\tBinlogDump := \u0026mysql.BinlogDump{\r\n\t\tDataSource:    DBsource,\r\n\t\tCallbackFun:   callback,\r\n\t\tReplicateDoDb: m,\r\n\t\tOnlyEvent:     []mysql.EventType{mysql.QUERY_EVENT, mysql.WRITE_ROWS_EVENTv1, mysql.UPDATE_ROWS_EVENTv1, mysql.DELETE_ROWS_EVENTv1,mysql.WRITE_ROWS_EVENTv2, mysql.UPDATE_ROWS_EVENTv2, mysql.DELETE_ROWS_EVENTv2},\r\n\t}\r\n\tgo BinlogDump.StartDumpBinlog(filename, position, 100,reslut,\"\",0)\r\n\tgo func() {\r\n\t\tfor {\r\n\t\t\tv := \u003c-reslut\r\n\t\t\tlog.Printf(\"monitor reslut:%s \\r\\n\", v)\r\n\t\t}\r\n\t}()\r\n\r\n\tfor {\r\n\t\ttime.Sleep(10 * time.Second)\r\n\t}\r\n\r\n`````\r\n\r\n#### 数据检验\r\n\r\n请参考 [一键数据检验测试工具](https://github.com/jc3wish/tree/master/Bristol/test)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrokercap%2Fbristol","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrokercap%2Fbristol","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrokercap%2Fbristol/lists"}