Reference Guide

Table Of Contents
implement com.hp.api.Distributable (a marker interface) to make it compatible with the
Coordination Service.
In terms of sharing these objects via the Coordination Service, the application developer
should consider which field(s) are required to constitute a version of the Model Object
versus which fields are optional. Commonly those fields that are defined in the objects
constructor arguments can be considered required fields for a version of the object. Later
versions may add additional optional fields to the object that are not set by a constructor.
New required fields may be added for new versions of the Model Object with their
presence as an argument in a new constructor. Note that adding new required fields will
require that field for future versions. Past versions of the application that receive a new
required field will just ignore it. Overall, thinking in terms of what fields are optional or
required will help with the next step in the definition of the GPB .proto message.
The following is an example of a Person Java class an application may want to define and
distribute via a PubSub Message Bus. The name and id fields are the only required as
indicated with the constructor arguments. The application may use other ways to indicate
what required fields are.
public class Person implements Distributable {
private String name;
private int id;
private String email;
private Date lastUpdated;
Person(String name, Id id) {
this.name = name;
this.id = id;
}
// Accessor and other methods.
}
GPB .proto Message
The GPB .proto message serves as the definition of a versioned message to be distributed
by the Coordination Service. The application developer should write the .proto messages
with the Model Object in mind when considering the data type of fields, whether they are
optional or required. etc. The developer should consider all the GPB versioning rules and
best practices mentioned in the previous section. The programmer implements a message
per Model Object that will be distributed following the GPB rules and conventions
previously discussed.
Below is an example .proto message for the Person class. The field data types and
REQUIRED/OPTIONAL tags match the Model Object. Since email was not a field to be set
in the constructor it is marked optional while name and id are marked as required. Notice
that lastUpdated field of the Model Object is not included in the .proto message definition.
This is considered a transient field, in the serialization sense, for the Model Object and it is
not meant to be distributed in any version of the message. With this example the reader can
81