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

Use protobuf JSON utilities for JSON (de-)serialisation #302

Merged
merged 4 commits into from
Apr 17, 2023

Conversation

csegarragonz
Copy link
Collaborator

@csegarragonz csegarragonz commented Apr 11, 2023

In this PR I switch from RapidJSON to protobuf-based JSON (de-)serialisation.

This change greatly simplifies the serialisation logic, and also makes it possible to (de-)serialise any other protobuf message that inherits from google::protobuf::Message.

The only downside is that the serialisation keys we manually set (i.e. py_user or py_func) are deeply embedded throughout the organisation's codebase. For example, in faasmcli or in the experiments repo. By default, protobuf sets its own keywords based on the proto file, but we can also force the serialisation name. We do the latter. I think I am not forgetting any keys, but there's no way to be really sure. I also add a regression test to make sure the keys we use elsewhere are always there in the form we expect them to be.

Closes #167

@csegarragonz csegarragonz self-assigned this Apr 11, 2023
@csegarragonz csegarragonz changed the title Protobuf json Use protobuf JSON utilities for JSON (de-)serialisation Apr 11, 2023
@csegarragonz csegarragonz requested a review from Shillaker April 11, 2023 15:59

faabric::Message jsonToMessage(const std::string& jsonIn);
void jsonToMessage(const std::string& jsonStr, google::protobuf::Message* msg);
Copy link
Collaborator Author

@csegarragonz csegarragonz Apr 12, 2023

Choose a reason for hiding this comment

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

I needed to change this signature, as we can not return an instance of the abstract class google::protobuf::Message.

Instead, we take the argument as a pointer.

@csegarragonz csegarragonz merged commit 02bb5a6 into main Apr 17, 2023
@csegarragonz csegarragonz deleted the protobuf-json branch April 17, 2023 09:11
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.

Replace use of RapidJSON with protobuf JSON utilities
1 participant