How to deprecate old, unused fields in gRPC
To prevent anyone from inserting fields into proto files with the same sequence numbers as the ones of the fields that have been removed, you can use the reserved
keyword. To use it, you just need to place it into your message
definition at the same level that you put your fields in.
To specify the field sequence numbers that you don't want anyone to use, you just place them after the reserved
keyword. If you need to specify multiple sequence numbers, you just separate them by a comma. Otherwise, you can specify a sequential range by using the to
keyword. For example, if you use 6 to 12
, all sequence numbers starting from 6
and ending with 12
will be unavailable. If you try to use them, you will receive an error when trying to generate code from the proto file.
There is also another way that you can use the reserved
keyword. Instead of specifying field sequence numbers, you can specify field names. If you do so, you will not be...