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

MySQL Binlog #11

Draft
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

0michalsokolowski0
Copy link

@0michalsokolowski0 0michalsokolowski0 commented Sep 6, 2020

Data mapping

In the current implementation of subscriber,
it is assumed that funtion UnmarshalMessage (SchemaAdapter) is used to extract data from a row. However, in the case of binlog I found this function
unusable because of the parameter *sql.Row. As a result I am inferring the content of columns based on separate configuration ColumnsMapping. Such an approach is
inspired by go-mysql-elasticsearch.
Could you express your opinion on that? Can you suggest a better solution?

Database Access

In the current implementation of subscriber,
database related interface is an argument passed to the constructor.
As for as I can see, it does not make much sense in the case of a binlog subscriber.

In order to initialize the subscriber, a canal to database's binlog files needs to be created.
The initialization require credentials and details of the database (expressed in Database struct)
this information is accessible only when explicitly passed to the subscriber which makes
beginner redundant.

Right now for simplicity I am using a hybrid solution, but it clearly needs correction.
I would like to remove usage of the interface from the constructor and initialize the connection to the database myself.
Could you express your opinion on that? Can you suggest a better solution?

TODO

  • Add tests for data mapping: mapRow, getBytes and getNumber.
  • Add tests for column mapping ColumnsMapping
  • Move and refactor Row struct
  • Refactor database access configuration (Database struct)
  • Add and improve comments

return errors.New("offsets adapter is nil")
}
if c.Database.Flavour != mysql.MySQLFlavor && c.Database.Flavour != mysql.MariaDBFlavor {
return errors.New("database config incorrect flavour value")
Copy link
Contributor

Choose a reason for hiding this comment

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

The error message could list the allowed flavours.
Otherwise, the consumer of the error will have to arrive to this line in the source code to find out what values are allowed.

@maclav3 maclav3 mentioned this pull request Sep 29, 2020
@blaggacao
Copy link

blaggacao commented Oct 31, 2020

Hello @0michalsokolowski0! Thank you for this!

I'm tasked with porting parts of a legacy message driven application to go, in which mutating the status column (by the legacy parts) are significant events. Is this branch currently usable for early incorporation? Do you expect the it's public API is still going to change?

@0michalsokolowski0
Copy link
Author

Hello @0michalsokolowski0! Thank you for this!

I'm tasked with porting parts of a legacy message driven application to go, in which mutating the status column (by the legacy parts) are significant events. Is this branch currently usable for early incorporation? Do you expect the it's public API is still going to change?

Hi @blaggacao ,

it is still work in progress and as I wrote above it needs to be tested more thoroughly.
Is this branch currently usable for early incorporation?
I don't think it is ready for usage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants