Skip to content
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

EventHandlerV2 support handle event with replication.EventHeader #740

Merged
merged 5 commits into from
Nov 30, 2022

Conversation

BLAZZ
Copy link
Contributor

@BLAZZ BLAZZ commented Nov 25, 2022

add EventHandlerV2 to get timestamp from event, so that canal can show the how much time delay when process like

func (s *handler) OnXID(header *replication.EventHeader, nextPos mysql.Position) error {
	s.queue <- model.Position{
		Name:      nextPos.Name,
		Pos:       nextPos.Pos,
		Timestamp: header.Timestamp,
		Force:     false,
	}
	return nil
}

it can show on UI like
binlog file: mysql-bin.000102
binlog position: 1142900
binlog timestamp: 2022-11-25 15:54:07 (1669362847)
tiem delay: 2 sec

@atercattus
Copy link
Member

Maybe we should change an EventHandler and increment semver as a major update?

@BLAZZ
Copy link
Contributor Author

BLAZZ commented Nov 25, 2022

Maybe we should change an EventHandler and increment semver as a major update?

change EventHandlerV2 name to another like EventHandlerWithHeader or change the method in EventHandler ?

@lance6716
Copy link
Collaborator

Maybe we should change an EventHandler and increment semver as a major update?

Oh i forget that for major version updates we can break compatibility. I agree with this.

Maybe we should change an EventHandler and increment semver as a major update?

change EventHandlerV2 name to another like EventHandlerWithHeader or change the method in EventHandler ?

It means we can change the API interface while keeping the old name EventHandler.

But because this chance is rare, we might ask other developers what they want to change and do them at once

canal/handler.go Outdated
@@ -40,3 +40,24 @@ func (h *DummyEventHandler) String() string { return "DummyEventHandler" }
func (c *Canal) SetEventHandler(h EventHandler) {
c.eventHandler = h
}

// EventHandlerV2 can process event with replication.EventHeader
type EventHandlerV2 interface {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry for my previous comments, now I think we can change the old EventHandler to this interface (will review more carefully later)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't forget this comment @BLAZZ

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have changed EventHandlerV2 to EventHandler

@lance6716
Copy link
Collaborator

please fix CI, some test files need to be updated

@lance6716 lance6716 merged commit 7685eee into go-mysql-org:master Nov 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants