core-java icon indicating copy to clipboard operation
core-java copied to clipboard

Clarify what the "first Message field" means

Open armiol opened this issue 4 years ago • 0 comments

We speak of the "first fields" in Protobuf messages on several occasions. In particular, we treat the "first Message field" as an identifier of the Entity — if the message declares an Entity state. Also, we speak of the Command's "first Message field" as of such specifying the ID of the command handling entity.

However, given the declaration:

message UserView {
    option (entity).kind = PROJECTION;

    UserName name = 2;
    UserId id = 1;
}

it difficult to tell, which field is meant as the "first" one.

Spine interprets the "first Message field" Spine as the first one in the order of reading. Not the one with the minimal index. Therefore, in the example above, the name field will be treated as a Projection identifier.

We do that because it's easier to read. And simpler to understand, as a developer does not have to read the whole message and sort the fields by their indexes on-the-fly.

Such a behavior is also helpful if we need to deprecate the ID field in favor of, let's say, a broader type. E.g. int32 to int64.

However, we lack the description of such a policy. This issue is about introducing one to both the corresponding Javadocs and the spine.io documentation.

armiol avatar Sep 09 '20 13:09 armiol