-
Notifications
You must be signed in to change notification settings - Fork 685
We need a logic to convert events into JSON format. #491
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
We need a logic to convert events into JSON format. #491
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think It might be a good idea to add some test cases.
if self.optional_metadata: | ||
result_dict.update(self.optional_metadata.to_json()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.optional_metadata always got object so it is Not None
optional_metadata = OptionalMetaData()
try this variable self.__optional_meta_data when check
and can we get some testcases?
def _to_json(self): | ||
gtid_event_dict = { | ||
"event_name": type(self).__name__, | ||
"commit": self.commit_flag, | ||
"gtid_next": self.gtid, | ||
} | ||
if hasattr(self, "last_committed"): | ||
gtid_event_dict["last_committed"] = self.last_committed | ||
gtid_event_dict["sequence_number"] = self.sequence_number | ||
return gtid_event_dict | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some test cases is more good for us
def _to_json(self): | ||
user_var_event_dict = { | ||
"event_name": type(self).__name__, | ||
"user_variable_name": self.name, | ||
} | ||
if not self.is_null: | ||
user_var_event_dict["type"] = self.type_to_codes_and_method.get( | ||
self.type, ["UNKNOWN_TYPE"] | ||
)[0] | ||
user_var_event_dict["charset"] = self.charset | ||
user_var_event_dict["value"] = self.value | ||
user_var_event_dict["flags"] = self.flags | ||
|
||
return user_var_event_dict | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some test cases is more good for us
def _to_json(self): | ||
return { | ||
"event_name": type(self).__name__, | ||
"schema": self.schema.decode("utf-8"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
563 Line I think it's better to send it in the same form as the dump, but what do you think?
Overview
In the majority of projects utilizing the
pymysqlreplication
library, it has been observed that binlog events are being converted into JSON format for usage.[Examples]
Streaming Changes in a Database with Amazon Kinesis
Near Zero Downtime Migration from MySQL to DynamoDB
Consequently, we have developed logic within our library to provide binlog events in JSON format.
How to execute
Results
Benefit
Through this logic, users can reduce the steps needed for additional processing.
The connection between heterogeneous software through JSON is expected to become more smooth and seamless.