- Notifications
You must be signed in to change notification settings - Fork 1k
Adding replication protocol support to mysql server implementation #759
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
15 commits Select commit Hold shift + click to select a range
2d8ffec feat: add new handler and errors
Fizic e96001b fix: error codes,
Fizic cae8dcf fix: Bug with use private method
Fizic c6e73da fix: errors
Fizic 132c325 fix: name in write value command
Fizic 5fdb922 fix: delete error from mysql errors, change errors in dispatch
Fizic d8ec4a6 fix: EmptyReplicationHandler methods
Fizic 4e4b1b5 fix: import
Fizic 125d938 fix: Replication handlers methods
Fizic d98f42c fix: golangci errors
Fizic 46a38cf fix: improved points in implementation, removed dangerous places that…
Fizic 09f1f26 fix: returned values in dispatch
Fizic 960c01a fix: external default in case, imports
Fizic 5f660c9 fix: parsing response
Fizic 60d5d2f Merge branch 'master' into master
lance6716 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix: improved points in implementation, removed dangerous places that…
… could lead to errors feat: comments explaining options, ReplicationHandler in tests
- Loading branch information
commit 46a38cfb3a08ea8dc2e6de663670922c8d8c378e
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| | @@ -32,10 +32,10 @@ type Handler interface { | |
| } | ||
| | ||
| type ReplicationHandler interface { | ||
| //handle Replication command | ||
| // handle Replication command | ||
| HandleRegisterSlave(data []byte) error | ||
| HandleBinlogDump(pos *Position, s *replication.BinlogStreamer) | ||
| HandleBinlogDumpGTID(gtidSet *MysqlGTIDSet, s *replication.BinlogStreamer) | ||
| HandleBinlogDump(pos *Position) (*replication.BinlogStreamer, error) | ||
| HandleBinlogDumpGTID(gtidSet *MysqlGTIDSet) (*replication.BinlogStreamer, error) | ||
| } | ||
| | ||
| func (c *Conn) HandleCommand() error { | ||
| | @@ -141,36 +141,34 @@ func (c *Conn) dispatch(data []byte) interface{} { | |
| return eofResponse{} | ||
| case COM_REGISTER_SLAVE: | ||
| if h, ok := c.h.(ReplicationHandler); ok { | ||
| if err := h.HandleRegisterSlave(data); err != nil { | ||
| return err | ||
| } | ||
| return nil | ||
| return h.HandleRegisterSlave(data) | ||
| } else { | ||
| return fmt.Errorf("the handler does not support replication protocol, use ReplicationHandler instead") | ||
| return c.h.HandleOtherCommand(cmd, data) | ||
| } | ||
| case COM_BINLOG_DUMP: | ||
| if h, ok := c.h.(ReplicationHandler); ok { | ||
| pos, _ := parseBinlogDump(data) | ||
| s := replication.NewBinlogStreamer() | ||
| go h.HandleBinlogDump(pos, s) | ||
| | ||
| return s | ||
| if s, err := h.HandleBinlogDump(pos); err != nil { | ||
| return s | ||
| } else { | ||
| return err | ||
| } | ||
| } else { | ||
| return fmt.Errorf("the handler does not support replication protocol, use ReplicationHandler instead") | ||
| return c.h.HandleOtherCommand(cmd, data) | ||
| } | ||
| case COM_BINLOG_DUMP_GTID: | ||
| if h, ok := c.h.(ReplicationHandler); ok { | ||
| gtidSet, err := parseBinlogDumpGTID(data) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| | ||
| s := replication.NewBinlogStreamer() | ||
| go h.HandleBinlogDumpGTID(gtidSet, s) | ||
| | ||
| return s | ||
| if s, err := h.HandleBinlogDumpGTID(gtidSet); err != nil { | ||
| return s | ||
| } else { | ||
| return err | ||
| } | ||
| } else { | ||
| return fmt.Errorf("the handler does not support replication protocol, use ReplicationHandler instead") | ||
| return c.h.HandleOtherCommand(cmd, data) | ||
| } | ||
| default: | ||
| return c.h.HandleOtherCommand(cmd, data) | ||
| | @@ -209,10 +207,12 @@ func (h EmptyReplicationHandler) HandleRegisterSlave(data []byte) error { | |
| return fmt.Errorf("not supported now") | ||
| } | ||
| | ||
| func (h EmptyReplicationHandler) HandleBinlogDump(pos *Position, r *replication.BinlogStreamer) { | ||
| func (h EmptyReplicationHandler) HandleBinlogDump(pos *Position) (*replication.BinlogStreamer, error) { | ||
| return nil, fmt.Errorf("not supported now") | ||
| } | ||
| | ||
| func (h EmptyReplicationHandler) HandleBinlogDumpGTID(gtidSet *MysqlGTIDSet, r *replication.BinlogStreamer) { | ||
| func (h EmptyReplicationHandler) HandleBinlogDumpGTID(gtidSet *MysqlGTIDSet) (*replication.BinlogStreamer, error) { | ||
| return nil, fmt.Errorf("not supported now") | ||
| } | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suggest adding | ||
| | ||
| func (h EmptyHandler) HandleOtherCommand(cmd byte, data []byte) error { | ||
| | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.