-
Notifications
You must be signed in to change notification settings - Fork 14.3k
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
Google Memcached hooks - improve protobuf messages handling #11743
Google Memcached hooks - improve protobuf messages handling #11743
Conversation
@@ -572,7 +571,7 @@ def _append_label(instance: cloud_memcache.Instance, key: str, val: str) -> clou | |||
@staticmethod | |||
def proto_message_to_dict(message: proto.Message) -> dict: | |||
"""Helper method to parse protobuf message to dictionary.""" | |||
return json.loads(message.__class__.to_json(message)) | |||
return message.__class__.to_dict(message) |
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.
Can you add comments in the code explaining why?
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.
This code has been deleted. Can you look again?
@@ -572,7 +571,7 @@ def _append_label(instance: cloud_memcache.Instance, key: str, val: str) -> clou | |||
@staticmethod | |||
def proto_message_to_dict(message: proto.Message) -> dict: | |||
"""Helper method to parse protobuf message to dictionary.""" | |||
return json.loads(message.__class__.to_json(message)) | |||
return message.__class__.to_dict(message) |
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.
Do we need this method at all? I think we can replace these methods with direct calls.
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 was thinking about it as well. Please check last updates to the PR.
0fc8add
to
7d1eca7
Compare
Use to_dict method introduced in proto-plus 1.11.0 instead if operating on json
7d1eca7
to
6c4d1fe
Compare
Use to_dict method introduced in
proto-plus 1.11.0
instead if operating on jsonRelated links:
googleapis/python-memcache#19 (comment)
googleapis/proto-plus-python#154
https://proto-plus-python.readthedocs.io/en/latest/messages.html#serialization