Proposal: Proto file generation for Protocol Buffers SerDes #3217
Labels
module/serdes
Issues related to the Ballerina serdes module
Status/Draft
In circulation by the author for initial review and consensus-building
Team/PCM
Protocol connector packages related issues
Type/Proposal
Summary
Ballerina SerDes module allows serializing/deserializing Ballerina
anydata
type to send them efficiently over the wire. TheProto3Schema
class of serdes module uses the protocol buffer as the underlying technology to perform serialization and deserialization of ballerina anydata types. It does so by dynamically generating a proto3 message definition for the given ballerina type. This proposal proposes an API to generate a proto3 file from the dynamically generated proto3 message definition.Goals
Motivation
A proto3 file generated using the proposed API can be used by network clients/ software written with other languages to generate native language bindings. These generated native language bindings can be used to send/receive messages to/from the ballerina side. Therefore, the proposed API provides a way to enable a language-neutral communication mechanism between ballerina and other languages. For example, if software written in java wants to send messages which need to be converted to a ballerina
anydata
subtype then the following steps can be doneDescription
The enhancement is to introduce an API to generate proto3 files so that the generated proto3 file can be used by clients/software written with other languages to receive/send messages from/to ballerina clients.
API
Approach 1
example:
The
generateProtoFile
function takes the file path and writes the file in the specified path or returns anError
on failure. On success the above example should produce a proto3 file with the content provided below.For more information about the ballerina type to protobuf message mapping refer serdes spec.
Approach 2
example:
The init function takes an optional
filePath
argument and writes the file in the specified path or returns anError
on failure.Approach Comparison
Approach 1
pros
Proto3Schema
classcons
Proto3Schema
classApproach 2
Someone can feel that generating a proto file is part of the initialization of the schema.
In that case, maybe passing an optional argument to the init function is a better way to generate the proto file.
pros
Proto3Schema
classcons
init
function does more than one thing. It generates a schema and generates the proto filefilePath
may confuse the userThe text was updated successfully, but these errors were encountered: