Adopting FieldMasks to reduce the payload
After improving our UpdateTasksRequest
message, we can now start looking at FieldMasks
to further reduce the payload size, but this time we are going to focus on ListTasksResponse
.
First, let us understand what FieldMasks
is. It refers to objects containing a list of paths telling Protobuf which fields to include and telling it implicitly which should not be included. An example of that could be the following. Saywe had a message such as Task
:
message Task { uint64 id = 1; string description = 2; bool done = 3; google.protobuf.Timestamp due_date = 4; }
And we wanted to select only id
and done
fields, we could have a simple FieldMask
like the following:
mask { paths: "id" paths: "done" }
We could then apply that mask on an instance of Task
and it would keep only the mentioned fields’ value. This is interesting when we are doing the...