Generate protobuf with stable ordered maps

The default marshalers from gogo-protobuf do not order keys, which means
successive serializations of the same data would result in same bytes.
Kubernetes leverages stable serialization to avoid excessive writes to
etcd when body content has not changed, which reduces the amount of
watch traffic generated by successive callers.

This will have a small memory impact on objects which have maps -
allocating a new string array for each map key. All maps must be keys
because we serialize those to JSON, so non-string types are not
relevant.
This commit is contained in:
Clayton Coleman 2017-06-17 09:05:14 -04:00
parent a57c33bd28
commit cdfbeff1ba
No known key found for this signature in database
GPG Key ID: 3D16906B4F1C5CB3

View File

@ -52,6 +52,7 @@ func (g *genProtoIDL) PackageVars(c *generator.Context) []string {
}
return []string{
"option (gogoproto.marshaler_all) = true;",
"option (gogoproto.stable_marshaler_all) = true;",
"option (gogoproto.sizer_all) = true;",
"option (gogoproto.goproto_stringer_all) = false;",
"option (gogoproto.stringer_all) = true;",