hide the revision field when it isn't populated

dependabot/go_modules/go.uber.org/atomic-1.10.0
ahrtr 2022-05-11 15:47:45 +08:00
parent 29d30ab7b0
commit beeb44d4ee
3 changed files with 10 additions and 3 deletions

View File

@ -275,7 +275,8 @@ type ResponseHeader struct {
ClusterId uint64 `protobuf:"varint,1,opt,name=cluster_id,json=clusterId,proto3" json:"cluster_id,omitempty"`
// member_id is the ID of the member which sent the response.
MemberId uint64 `protobuf:"varint,2,opt,name=member_id,json=memberId,proto3" json:"member_id,omitempty"`
// revision is the key-value store revision when the request was applied.
// revision is the key-value store revision when the request was applied, and it's
// unset (so 0) in case of calls not interacting with key-value store.
// For watch progress responses, the header.revision indicates progress. All future events
// received in this stream are guaranteed to have a higher revision number than the
// header.revision number.

View File

@ -395,7 +395,8 @@ message ResponseHeader {
uint64 cluster_id = 1;
// member_id is the ID of the member which sent the response.
uint64 member_id = 2;
// revision is the key-value store revision when the request was applied.
// revision is the key-value store revision when the request was applied, and it's
// unset (so 0) in case of calls not interacting with key-value store.
// For watch progress responses, the header.revision indicates progress. All future events
// received in this stream are guaranteed to have a higher revision number than the
// header.revision number.

View File

@ -36,7 +36,12 @@ func (p *fieldsPrinter) kv(pfx string, kv *spb.KeyValue) {
func (p *fieldsPrinter) hdr(h *pb.ResponseHeader) {
fmt.Println(`"ClusterID" :`, h.ClusterId)
fmt.Println(`"MemberID" :`, h.MemberId)
fmt.Println(`"Revision" :`, h.Revision)
// Revision only makes sense for k/v responses. For other kinds of
// responses, i.e. MemberList, usually the revision isn't populated
// at all; so it would be better to hide this field in these cases.
if h.Revision > 0 {
fmt.Println(`"Revision" :`, h.Revision)
}
fmt.Println(`"RaftTerm" :`, h.RaftTerm)
}