External Issue: Review of protobuf user-end APIs

16207, “Aniket21mathur”, “Review of protobuf user-end APIs”, “2020-08-06T15:41:06Z”

We now have a Chapel plugin for the protoc compiler and a user module for supporting protobuf operations. The pull request for integrating the work with chapel master is under review.

Meanwhile, it is important that we have a good feedback on the names of user-end functions. For now, the generated Chapel code for a message includes 2 user-facing methods-

  • writeToOutputFile(ch) - This function enables the user to serialize proto messages into protobuf binary wire format through a writing channel to an output file.

  • parseFromInputFile(ch) - This function enables the user to parse proto messages from an input file through a reading channel.

Example usage of the methods through a generated chpl file from a source proto file.

example.proto(source proto file)

syntax = "proto3";

message exampleMessage {
  int64 testField = 1;
}

example.chpl (Mock generated chapel file)

module example {  // Generated by the protocol buffer compiler.
  ...
  record exampleMessage {
    var testField: int(64);
    proc writeToOutputFile(ch) throws { ... }
    proc parseFromInputFile(ch) throws { ... }
  }
}

write.chpl(code written by a user to set message field values and serialize these to byte stream)

use example;
use IO;

var file = open("out", iomode.cw);
var writingChannel = file.writer();

var messageObj: exampleMessage;
messageObj.testField = 9223;

messageObj.writeToOutputFile(writingChannel);

read.chpl(code written by another user to parse the input byte stream and access the set message field values )

use example;
use IO;

var messageObj: exampleMessage;
var file = open("out", iomode.r);
var readingChannel = file.reader();

messageObj.parseFromInputFile(readingChannel);

writeln(messageObj.testField == 9223); // Prints true

What names should we use for the methods currently called writeToOutputFile and parseFromInputFile in Chapel for writing and parsing respectively?

Common method names used by other languages are -