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.
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 functionunusable because of the parameter
*sql.Row
. As a result I am inferring the content of columns based on separate configurationColumnsMapping
. Such an approach isinspired 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
mapRow
,getBytes
andgetNumber
.ColumnsMapping
Row struct
Database
struct)