Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Background

Protocol

We've been writing a new client-server protocol as a public API for the creation of new Geode clients. We settled on using Protobuf as the encoding for the protocol as it allows a user not to think about a lot of the encoding details, which makes writing clients significantly easier.

...

The message for sending a type definition will look like this:

Code Block
titleProtobuf Type registration
linenumberstrue
collapsetrue
message TypeRegistrationRequest {
  ValueTypeDefinition typeDefinition = 1;
}
message TypeRegistrationResponse {
  int typeID = 1;
}

message ValueTypeDefinition {
  string typeName = 1;
  repeated ValueTypeFieldDefinition definition = 2;
}
message ValueTypeFieldDefinition {
  string fieldName = 1;
  enum fieldType {
    intField;
    longField;
    shortField;
    byteField;
    booleanField;
    doubleField;
    floatField;
    binaryField;
    stringField;
    // no JSON?  string jsonObjectField;
    // Field serialized using a custom serialization format. This can only be used if
    // A HandshakeRequest is sent with valueFormat set to a valid format.
    //
    // See HandshakeRequest.valueFormat.
    customObjectField;
  }
}

...

Code Block
languagetext
titleProtobut type registrationValues
linenumberstrue
collapsetrue
message Value {
  int typeID = 1;
  repeated ValueField field = 2;
}
message ValueField = {
  oneof value {
    int32 intField = 1;
    int64 longField = 2;
    int32 shortField = 3;
    byte byteField = 4;
    bool booleanField = 5;
    double doubleField = 6;
    float floatField = 7;
    bytes binaryField = 8;
    string stringField = 9;
    google.protobuf.NullValue nullField = 11;
    // Field serialized using a custom serialization format. This can only be used if
    // A HandshakeRequest is sent with valueFormat set to a valid format.
    //
    // See HandshakeRequest.valueFormat.
    bytes customObjectField = 12;
  }
}

...