From 881fcbf5bc41a492d77db7a27f07ffe5088df6dc Mon Sep 17 00:00:00 2001 From: Hu# Date: Thu, 22 Feb 2024 10:43:02 +0800 Subject: [PATCH 1/2] proto/meta_storagepb.proto: support meta delete client interface (#1226) * add Delete Signed-off-by: husharp --- pkg/meta_storagepb/meta_storagepb.pb.go | 829 +++++++++++++++++++++--- proto/meta_storagepb.proto | 94 ++- scripts/check.sh | 4 +- scripts/proto.lock | 51 ++ 4 files changed, 867 insertions(+), 111 deletions(-) diff --git a/pkg/meta_storagepb/meta_storagepb.pb.go b/pkg/meta_storagepb/meta_storagepb.pb.go index 4d3958a0c..b4c31cc8e 100644 --- a/pkg/meta_storagepb/meta_storagepb.pb.go +++ b/pkg/meta_storagepb/meta_storagepb.pb.go @@ -79,7 +79,7 @@ func (x Event_EventType) String() string { } func (Event_EventType) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_5a2dc828c1dd8152, []int{10, 0} + return fileDescriptor_5a2dc828c1dd8152, []int{12, 0} } type Error struct { @@ -690,6 +690,149 @@ func (m *PutResponse) GetPrevKv() *KeyValue { return nil } +// copied from etcd https://github.com/etcd-io/etcd/blob/7dfd29b0cc7ce25337276dce646ca2a65aa44b4d/api/mvccpb/kv.proto +type DeleteRequest struct { + Header *RequestHeader `protobuf:"bytes,1,opt,name=header,proto3" json:"header,omitempty"` + Key []byte `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"` + // range_end is the key following the last key to delete for the range [key, range_end). + // If range_end is not given, the range is defined to contain only the key argument. + // If range_end is one bit larger than the given key, then the range is all the keys + // with the prefix (the given key). + // If range_end is '\0', the range is all keys greater than or equal to the key argument. + RangeEnd []byte `protobuf:"bytes,3,opt,name=range_end,json=rangeEnd,proto3" json:"range_end,omitempty"` + // If prev_kv is set, etcd gets the previous key-value pairs before deleting it. + // The previous key-value pairs will be returned in the delete response. + PrevKv bool `protobuf:"varint,4,opt,name=prev_kv,json=prevKv,proto3" json:"prev_kv,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *DeleteRequest) Reset() { *m = DeleteRequest{} } +func (m *DeleteRequest) String() string { return proto.CompactTextString(m) } +func (*DeleteRequest) ProtoMessage() {} +func (*DeleteRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_5a2dc828c1dd8152, []int{9} +} +func (m *DeleteRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *DeleteRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DeleteRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *DeleteRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_DeleteRequest.Merge(m, src) +} +func (m *DeleteRequest) XXX_Size() int { + return m.Size() +} +func (m *DeleteRequest) XXX_DiscardUnknown() { + xxx_messageInfo_DeleteRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_DeleteRequest proto.InternalMessageInfo + +func (m *DeleteRequest) GetHeader() *RequestHeader { + if m != nil { + return m.Header + } + return nil +} + +func (m *DeleteRequest) GetKey() []byte { + if m != nil { + return m.Key + } + return nil +} + +func (m *DeleteRequest) GetRangeEnd() []byte { + if m != nil { + return m.RangeEnd + } + return nil +} + +func (m *DeleteRequest) GetPrevKv() bool { + if m != nil { + return m.PrevKv + } + return false +} + +type DeleteResponse struct { + Header *ResponseHeader `protobuf:"bytes,1,opt,name=header,proto3" json:"header,omitempty"` + // deleted is the number of keys deleted by the delete range request. + Deleted int64 `protobuf:"varint,2,opt,name=deleted,proto3" json:"deleted,omitempty"` + PrevKvs []*KeyValue `protobuf:"bytes,3,rep,name=prev_kvs,json=prevKvs,proto3" json:"prev_kvs,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *DeleteResponse) Reset() { *m = DeleteResponse{} } +func (m *DeleteResponse) String() string { return proto.CompactTextString(m) } +func (*DeleteResponse) ProtoMessage() {} +func (*DeleteResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_5a2dc828c1dd8152, []int{10} +} +func (m *DeleteResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *DeleteResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DeleteResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *DeleteResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_DeleteResponse.Merge(m, src) +} +func (m *DeleteResponse) XXX_Size() int { + return m.Size() +} +func (m *DeleteResponse) XXX_DiscardUnknown() { + xxx_messageInfo_DeleteResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_DeleteResponse proto.InternalMessageInfo + +func (m *DeleteResponse) GetHeader() *ResponseHeader { + if m != nil { + return m.Header + } + return nil +} + +func (m *DeleteResponse) GetDeleted() int64 { + if m != nil { + return m.Deleted + } + return 0 +} + +func (m *DeleteResponse) GetPrevKvs() []*KeyValue { + if m != nil { + return m.PrevKvs + } + return nil +} + // copied from etcd https://github.com/etcd-io/etcd/blob/7dfd29b0cc7ce25337276dce646ca2a65aa44b4d/api/mvccpb/kv.proto type KeyValue struct { // key is the key in bytes. An empty key is not allowed. @@ -717,7 +860,7 @@ func (m *KeyValue) Reset() { *m = KeyValue{} } func (m *KeyValue) String() string { return proto.CompactTextString(m) } func (*KeyValue) ProtoMessage() {} func (*KeyValue) Descriptor() ([]byte, []int) { - return fileDescriptor_5a2dc828c1dd8152, []int{9} + return fileDescriptor_5a2dc828c1dd8152, []int{11} } func (m *KeyValue) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -811,7 +954,7 @@ func (m *Event) Reset() { *m = Event{} } func (m *Event) String() string { return proto.CompactTextString(m) } func (*Event) ProtoMessage() {} func (*Event) Descriptor() ([]byte, []int) { - return fileDescriptor_5a2dc828c1dd8152, []int{10} + return fileDescriptor_5a2dc828c1dd8152, []int{12} } func (m *Event) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -873,6 +1016,8 @@ func init() { proto.RegisterType((*GetResponse)(nil), "meta_storagepb.GetResponse") proto.RegisterType((*PutRequest)(nil), "meta_storagepb.PutRequest") proto.RegisterType((*PutResponse)(nil), "meta_storagepb.PutResponse") + proto.RegisterType((*DeleteRequest)(nil), "meta_storagepb.DeleteRequest") + proto.RegisterType((*DeleteResponse)(nil), "meta_storagepb.DeleteResponse") proto.RegisterType((*KeyValue)(nil), "meta_storagepb.KeyValue") proto.RegisterType((*Event)(nil), "meta_storagepb.Event") } @@ -880,56 +1025,60 @@ func init() { func init() { proto.RegisterFile("meta_storagepb.proto", fileDescriptor_5a2dc828c1dd8152) } var fileDescriptor_5a2dc828c1dd8152 = []byte{ - // 777 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x55, 0x41, 0x6f, 0xda, 0x58, - 0x10, 0xe6, 0x61, 0x6c, 0x60, 0x20, 0xc4, 0x7a, 0x62, 0x77, 0xbd, 0x64, 0xc3, 0xb2, 0x96, 0x76, - 0x97, 0xcd, 0x2a, 0xec, 0x2e, 0xd9, 0xf6, 0xdc, 0x34, 0xa1, 0x49, 0x45, 0x93, 0x20, 0x97, 0x34, - 0x47, 0xe4, 0xc0, 0x88, 0x20, 0x02, 0xa6, 0xcf, 0xcf, 0x56, 0xf8, 0x27, 0x55, 0x7b, 0xaa, 0xd4, - 0x43, 0x4f, 0x3d, 0xf5, 0xd6, 0x3f, 0xd0, 0x63, 0x8f, 0x95, 0x7a, 0xa9, 0xd2, 0x3f, 0x52, 0xf9, - 0xd9, 0x18, 0xe3, 0x10, 0x29,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 0x62, 0x9e, 0x3b, 0x68, 0x78, 0x41, 0x94, 0x42, 0x6a, 0x64, 0x31, 0x14, 0xec, 0x33, 0x86, - 0x38, 0x7b, 0xcc, 0xbb, 0x96, 0x33, 0x0e, 0x99, 0x0b, 0x43, 0x7f, 0x4e, 0x00, 0x5a, 0xce, 0xb7, - 0x17, 0xb1, 0x08, 0xb2, 0xeb, 0xf1, 0x09, 0x04, 0xf4, 0x0d, 0xa1, 0x1e, 0x9a, 0x36, 0x86, 0xea, - 0x79, 0xc6, 0xf5, 0x5d, 0x78, 0x01, 0x39, 0xc1, 0xed, 0x96, 0xca, 0xfd, 0x37, 0xc7, 0xf7, 0xc7, - 0xf9, 0x7a, 0xf5, 0x66, 0x99, 0xdf, 0x10, 0xc8, 0xcc, 0x9c, 0xb3, 0xea, 0xc8, 0xbc, 0xba, 0x3f, - 0x61, 0xb5, 0xcb, 0xd0, 0xe4, 0x18, 0xef, 0xe9, 0x82, 0xef, 0x0e, 0x5b, 0xfa, 0x37, 0xc8, 0x8f, - 0xac, 0x5e, 0x27, 0xb6, 0x1e, 0x72, 0x23, 0xab, 0x17, 0x86, 0x68, 0x90, 0x76, 0x91, 0x45, 0x66, - 0x74, 0x66, 0xce, 0x35, 0x94, 0x97, 0x6a, 0xa8, 0x44, 0x34, 0xd4, 0xdf, 0x11, 0x90, 0xc5, 0x78, - 0xd0, 0xad, 0x85, 0xe5, 0xfb, 0xeb, 0xd2, 0x19, 0xf2, 0x7f, 0x23, 0x2b, 0xb8, 0x0a, 0xc9, 0x1b, - 0xa8, 0x93, 0x1c, 0xba, 0x51, 0x31, 0xa5, 0x1b, 0x8a, 0x59, 0x81, 0x6c, 0x98, 0x8f, 0xa6, 0x41, - 0x6a, 0x1d, 0xb7, 0xd5, 0x04, 0x05, 0x50, 0x76, 0x1b, 0x8f, 0x1a, 0xed, 0x86, 0x4a, 0x36, 0xfe, - 0x87, 0x6c, 0xf8, 0x28, 0x50, 0x05, 0x92, 0x47, 0x4d, 0x35, 0x41, 0x73, 0x90, 0x3e, 0x3e, 0x6c, - 0x1e, 0x1e, 0x9d, 0x1c, 0xaa, 0x84, 0x52, 0x28, 0xec, 0x6e, 0xb7, 0xb7, 0x3b, 0x3b, 0x47, 0x07, - 0xad, 0xed, 0x9d, 0x76, 0x63, 0x57, 0x4d, 0xd6, 0x3f, 0x11, 0xc8, 0x1d, 0x20, 0x37, 0x1f, 0xfb, - 0xa9, 0xe9, 0x3e, 0xc8, 0x62, 0x67, 0xd1, 0x5f, 0xe2, 0x94, 0xa2, 0x1b, 0xb8, 0xb4, 0x7e, 0xcd, - 0xad, 0xdf, 0x3b, 0x7a, 0xe2, 0x5f, 0x42, 0xef, 0x81, 0xb4, 0x87, 0x9c, 0x96, 0xe2, 0x91, 0xf3, - 0x75, 0x53, 0x5a, 0x5b, 0x7a, 0x37, 0xc3, 0xf0, 0x10, 0x5a, 0xce, 0x12, 0x84, 0xf9, 0xac, 0x5d, - 0x45, 0x88, 0xf4, 0xba, 0x9e, 0xb8, 0xff, 0xc7, 0xc7, 0xd7, 0x19, 0xf2, 0xfe, 0xb2, 0x4c, 0x3e, - 0x5c, 0x96, 0xc9, 0xe7, 0xcb, 0x32, 0x79, 0xf6, 0xa5, 0x9c, 0x00, 0xd5, 0x62, 0xfd, 0x1a, 0x1f, - 0x0c, 0xdd, 0xda, 0xd0, 0x15, 0xaf, 0xee, 0xa9, 0x22, 0xfe, 0xb6, 0xbe, 0x06, 0x00, 0x00, 0xff, - 0xff, 0xfd, 0xde, 0x7c, 0x36, 0xcb, 0x07, 0x00, 0x00, + // 843 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x56, 0xcd, 0x8e, 0xe3, 0x44, + 0x10, 0x4e, 0xdb, 0xb1, 0x93, 0x54, 0x7e, 0xc6, 0x6a, 0x05, 0x30, 0x59, 0x26, 0x04, 0x4b, 0x40, + 0x58, 0xb4, 0x01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 0xdc, + 0x9a, 0x51, 0x90, 0xf1, 0x33, 0x01, 0x78, 0x82, 0xfc, 0x7e, 0x85, 0xad, 0x83, 0xb2, 0x98, 0x2d, + 0x67, 0x3c, 0xd2, 0x33, 0x34, 0x76, 0x3a, 0x40, 0xc9, 0x74, 0xc0, 0x8f, 0x04, 0xca, 0x82, 0xe6, + 0x1d, 0x85, 0x7c, 0x08, 0xf2, 0xdc, 0x77, 0x75, 0x49, 0x48, 0xa3, 0x67, 0x7f, 0x34, 0xc0, 0xcd, + 0xd7, 0xd6, 0xc2, 0x43, 0x33, 0x08, 0xa2, 0x14, 0xf2, 0x4b, 0x87, 0xa1, 0x60, 0x5f, 0x34, 0xc5, + 0x39, 0x60, 0x3e, 0x71, 0xbc, 0x55, 0xc2, 0x5c, 0x18, 0xc6, 0x0f, 0x04, 0x60, 0xe8, 0xfd, 0xff, + 0x22, 0xd6, 0x41, 0xf1, 0x03, 0x3e, 0x91, 0x80, 0xa1, 0x21, 0xd4, 0x43, 0xcb, 0xc5, 0x44, 0xbd, + 0xc0, 0x38, 0xdc, 0x85, 0x57, 0x50, 0x16, 0xdc, 0xee, 0xa8, 0xdc, 0x47, 0x5b, 0xfc, 0x70, 0x9c, + 0x0f, 0xab, 0x17, 0x67, 0xfe, 0x96, 0x40, 0xb5, 0x87, 0x0b, 0xe4, 0x78, 0xbf, 0xed, 0x95, 0x92, + 0x22, 0xbf, 0x23, 0xc5, 0x77, 0x04, 0x6a, 0x31, 0xa1, 0x3b, 0xca, 0xa1, 0x43, 0xc1, 0x16, 0x48, + 0x76, 0x34, 0x88, 0xb1, 0x49, 0x4f, 0xa0, 0x18, 0x65, 0x8f, 0x47, 0xf0, 0xb0, 0x52, 0x85, 0x90, + 0x98, 0x6b, 0xfc, 0x46, 0xa0, 0x18, 0x7b, 0xe3, 0x72, 0xc9, 0xb6, 0xdc, 0x77, 0xe1, 0x68, 0xc2, + 0xd0, 0xe2, 0x98, 0x1d, 0xff, 0x5a, 0xe8, 0x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xc2, 0x76, 0x2d, 0xdd, + 0x44, 0x48, 0xad, 0x05, 0x23, 0x47, 0x9f, 0x81, 0x1a, 0xce, 0x06, 0xbd, 0x41, 0x78, 0x67, 0x88, + 0x1b, 0xcd, 0x43, 0xd7, 0x31, 0xd4, 0xe7, 0xef, 0xfc, 0xfd, 0x6b, 0x91, 0xfc, 0x79, 0xdd, 0x24, + 0x7f, 0x5d, 0x37, 0xc9, 0x3f, 0xd7, 0x4d, 0xf2, 0xfd, 0xbf, 0xcd, 0x1c, 0x68, 0x0e, 0x9b, 0x76, + 0xf8, 0x6c, 0xee, 0x77, 0xe6, 0xbe, 0xf8, 0xaf, 0x73, 0xa1, 0x8a, 0xaf, 0x93, 0xff, 0x02, 0x00, + 0x00, 0xff, 0xff, 0x4d, 0xff, 0x95, 0xca, 0x41, 0x09, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -949,6 +1098,9 @@ type MetaStorageClient interface { // so that we can use other storages to replace etcd in the future. Get(ctx context.Context, in *GetRequest, opts ...grpc.CallOption) (*GetResponse, error) Put(ctx context.Context, in *PutRequest, opts ...grpc.CallOption) (*PutResponse, error) + // Delete is the same as etcd Range which might be implemented in a more common way + // so that we can use other storages to replace etcd in the future. + Delete(ctx context.Context, in *DeleteRequest, opts ...grpc.CallOption) (*DeleteResponse, error) } type metaStorageClient struct { @@ -1009,6 +1161,15 @@ func (c *metaStorageClient) Put(ctx context.Context, in *PutRequest, opts ...grp return out, nil } +func (c *metaStorageClient) Delete(ctx context.Context, in *DeleteRequest, opts ...grpc.CallOption) (*DeleteResponse, error) { + out := new(DeleteResponse) + err := c.cc.Invoke(ctx, "/meta_storagepb.MetaStorage/Delete", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MetaStorageServer is the server API for MetaStorage service. type MetaStorageServer interface { Watch(*WatchRequest, MetaStorage_WatchServer) error @@ -1016,6 +1177,9 @@ type MetaStorageServer interface { // so that we can use other storages to replace etcd in the future. Get(context.Context, *GetRequest) (*GetResponse, error) Put(context.Context, *PutRequest) (*PutResponse, error) + // Delete is the same as etcd Range which might be implemented in a more common way + // so that we can use other storages to replace etcd in the future. + Delete(context.Context, *DeleteRequest) (*DeleteResponse, error) } // UnimplementedMetaStorageServer can be embedded to have forward compatible implementations. @@ -1031,6 +1195,9 @@ func (*UnimplementedMetaStorageServer) Get(ctx context.Context, req *GetRequest) func (*UnimplementedMetaStorageServer) Put(ctx context.Context, req *PutRequest) (*PutResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Put not implemented") } +func (*UnimplementedMetaStorageServer) Delete(ctx context.Context, req *DeleteRequest) (*DeleteResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Delete not implemented") +} func RegisterMetaStorageServer(s *grpc.Server, srv MetaStorageServer) { s.RegisterService(&_MetaStorage_serviceDesc, srv) @@ -1093,6 +1260,24 @@ func _MetaStorage_Put_Handler(srv interface{}, ctx context.Context, dec func(int return interceptor(ctx, in, info, handler) } +func _MetaStorage_Delete_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DeleteRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MetaStorageServer).Delete(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/meta_storagepb.MetaStorage/Delete", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MetaStorageServer).Delete(ctx, req.(*DeleteRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _MetaStorage_serviceDesc = grpc.ServiceDesc{ ServiceName: "meta_storagepb.MetaStorage", HandlerType: (*MetaStorageServer)(nil), @@ -1105,6 +1290,10 @@ var _MetaStorage_serviceDesc = grpc.ServiceDesc{ MethodName: "Put", Handler: _MetaStorage_Put_Handler, }, + { + MethodName: "Delete", + Handler: _MetaStorage_Delete_Handler, + }, }, Streams: []grpc.StreamDesc{ { @@ -1619,6 +1808,127 @@ func (m *PutResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *DeleteRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *DeleteRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *DeleteRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) + } + if m.PrevKv { + i-- + if m.PrevKv { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x20 + } + if len(m.RangeEnd) > 0 { + i -= len(m.RangeEnd) + copy(dAtA[i:], m.RangeEnd) + i = encodeVarintMetaStoragepb(dAtA, i, uint64(len(m.RangeEnd))) + i-- + dAtA[i] = 0x1a + } + if len(m.Key) > 0 { + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = encodeVarintMetaStoragepb(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0x12 + } + if m.Header != nil { + { + size, err := m.Header.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintMetaStoragepb(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *DeleteResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *DeleteResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *DeleteResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) + } + if len(m.PrevKvs) > 0 { + for iNdEx := len(m.PrevKvs) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.PrevKvs[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintMetaStoragepb(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if m.Deleted != 0 { + i = encodeVarintMetaStoragepb(dAtA, i, uint64(m.Deleted)) + i-- + dAtA[i] = 0x10 + } + if m.Header != nil { + { + size, err := m.Header.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintMetaStoragepb(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *KeyValue) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1970,31 +2280,26 @@ func (m *PutResponse) Size() (n int) { return n } -func (m *KeyValue) Size() (n int) { +func (m *DeleteRequest) Size() (n int) { if m == nil { return 0 } var l int _ = l + if m.Header != nil { + l = m.Header.Size() + n += 1 + l + sovMetaStoragepb(uint64(l)) + } l = len(m.Key) if l > 0 { n += 1 + l + sovMetaStoragepb(uint64(l)) } - if m.CreateRevision != 0 { - n += 1 + sovMetaStoragepb(uint64(m.CreateRevision)) - } - if m.ModRevision != 0 { - n += 1 + sovMetaStoragepb(uint64(m.ModRevision)) - } - if m.Version != 0 { - n += 1 + sovMetaStoragepb(uint64(m.Version)) - } - l = len(m.Value) + l = len(m.RangeEnd) if l > 0 { n += 1 + l + sovMetaStoragepb(uint64(l)) } - if m.Lease != 0 { - n += 1 + sovMetaStoragepb(uint64(m.Lease)) + if m.PrevKv { + n += 2 } if m.XXX_unrecognized != nil { n += len(m.XXX_unrecognized) @@ -2002,24 +2307,81 @@ func (m *KeyValue) Size() (n int) { return n } -func (m *Event) Size() (n int) { +func (m *DeleteResponse) Size() (n int) { if m == nil { return 0 } var l int _ = l - if m.Type != 0 { - n += 1 + sovMetaStoragepb(uint64(m.Type)) - } - if m.Kv != nil { - l = m.Kv.Size() + if m.Header != nil { + l = m.Header.Size() n += 1 + l + sovMetaStoragepb(uint64(l)) } - if m.PrevKv != nil { - l = m.PrevKv.Size() - n += 1 + l + sovMetaStoragepb(uint64(l)) + if m.Deleted != 0 { + n += 1 + sovMetaStoragepb(uint64(m.Deleted)) } - if m.XXX_unrecognized != nil { + if len(m.PrevKvs) > 0 { + for _, e := range m.PrevKvs { + l = e.Size() + n += 1 + l + sovMetaStoragepb(uint64(l)) + } + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *KeyValue) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Key) + if l > 0 { + n += 1 + l + sovMetaStoragepb(uint64(l)) + } + if m.CreateRevision != 0 { + n += 1 + sovMetaStoragepb(uint64(m.CreateRevision)) + } + if m.ModRevision != 0 { + n += 1 + sovMetaStoragepb(uint64(m.ModRevision)) + } + if m.Version != 0 { + n += 1 + sovMetaStoragepb(uint64(m.Version)) + } + l = len(m.Value) + if l > 0 { + n += 1 + l + sovMetaStoragepb(uint64(l)) + } + if m.Lease != 0 { + n += 1 + sovMetaStoragepb(uint64(m.Lease)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *Event) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Type != 0 { + n += 1 + sovMetaStoragepb(uint64(m.Type)) + } + if m.Kv != nil { + l = m.Kv.Size() + n += 1 + l + sovMetaStoragepb(uint64(l)) + } + if m.PrevKv != nil { + l = m.PrevKv.Size() + n += 1 + l + sovMetaStoragepb(uint64(l)) + } + if m.XXX_unrecognized != nil { n += len(m.XXX_unrecognized) } return n @@ -3364,6 +3726,321 @@ func (m *PutResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *DeleteRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetaStoragepb + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: DeleteRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DeleteRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetaStoragepb + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthMetaStoragepb + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthMetaStoragepb + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Header == nil { + m.Header = &RequestHeader{} + } + if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetaStoragepb + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthMetaStoragepb + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthMetaStoragepb + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...) + if m.Key == nil { + m.Key = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RangeEnd", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetaStoragepb + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthMetaStoragepb + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthMetaStoragepb + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RangeEnd = append(m.RangeEnd[:0], dAtA[iNdEx:postIndex]...) + if m.RangeEnd == nil { + m.RangeEnd = []byte{} + } + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PrevKv", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetaStoragepb + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.PrevKv = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skipMetaStoragepb(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthMetaStoragepb + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *DeleteResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetaStoragepb + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: DeleteResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DeleteResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetaStoragepb + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthMetaStoragepb + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthMetaStoragepb + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Header == nil { + m.Header = &ResponseHeader{} + } + if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Deleted", wireType) + } + m.Deleted = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetaStoragepb + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Deleted |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PrevKvs", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetaStoragepb + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthMetaStoragepb + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthMetaStoragepb + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PrevKvs = append(m.PrevKvs, &KeyValue{}) + if err := m.PrevKvs[len(m.PrevKvs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipMetaStoragepb(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthMetaStoragepb + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *KeyValue) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/proto/meta_storagepb.proto b/proto/meta_storagepb.proto index bae7ae572..fba22bd1f 100644 --- a/proto/meta_storagepb.proto +++ b/proto/meta_storagepb.proto @@ -20,6 +20,10 @@ service MetaStorage { rpc Get(GetRequest) returns (GetResponse) {} rpc Put(PutRequest) returns (PutResponse) {} + + // Delete is the same as etcd Range which might be implemented in a more common way + // so that we can use other storages to replace etcd in the future. + rpc Delete(DeleteRequest) returns (DeleteResponse) {} } enum ErrorType { @@ -96,43 +100,67 @@ message PutResponse { KeyValue prev_kv = 2; } +// copied from etcd https://github.com/etcd-io/etcd/blob/7dfd29b0cc7ce25337276dce646ca2a65aa44b4d/api/mvccpb/kv.proto +message DeleteRequest { + RequestHeader header = 1; + bytes key = 2; + // range_end is the key following the last key to delete for the range [key, range_end). + // If range_end is not given, the range is defined to contain only the key argument. + // If range_end is one bit larger than the given key, then the range is all the keys + // with the prefix (the given key). + // If range_end is '\0', the range is all keys greater than or equal to the key argument. + bytes range_end = 3; + + // If prev_kv is set, etcd gets the previous key-value pairs before deleting it. + // The previous key-value pairs will be returned in the delete response. + bool prev_kv = 4; +} + +message DeleteResponse { + ResponseHeader header = 1; + // deleted is the number of keys deleted by the delete range request. + int64 deleted = 2; + repeated KeyValue prev_kvs = 3; +} + + // copied from etcd https://github.com/etcd-io/etcd/blob/7dfd29b0cc7ce25337276dce646ca2a65aa44b4d/api/mvccpb/kv.proto message KeyValue { - // key is the key in bytes. An empty key is not allowed. - bytes key = 1; - // create_revision is the revision of last creation on this key. - int64 create_revision = 2; - // mod_revision is the revision of last modification on this key. - int64 mod_revision = 3; - // version is the version of the key. A deletion resets - // the version to zero and any modification of the key - // increases its version. - int64 version = 4; - // value is the value held by the key, in bytes. - bytes value = 5; - // lease is the ID of the lease that attached to key. - // When the attached lease expires, the key will be deleted. - // If lease is 0, then no lease is attached to the key. - int64 lease = 6; + // key is the key in bytes. An empty key is not allowed. + bytes key = 1; + // create_revision is the revision of last creation on this key. + int64 create_revision = 2; + // mod_revision is the revision of last modification on this key. + int64 mod_revision = 3; + // version is the version of the key. A deletion resets + // the version to zero and any modification of the key + // increases its version. + int64 version = 4; + // value is the value held by the key, in bytes. + bytes value = 5; + // lease is the ID of the lease that attached to key. + // When the attached lease expires, the key will be deleted. + // If lease is 0, then no lease is attached to the key. + int64 lease = 6; } // copied from etcd https://github.com/etcd-io/etcd/blob/7dfd29b0cc7ce25337276dce646ca2a65aa44b4d/api/mvccpb/kv.proto message Event { - enum EventType { - PUT = 0; - DELETE = 1; - } - // type is the kind of event. If type is a PUT, it indicates - // new data has been stored to the key. If type is a DELETE, - // it indicates the key was deleted. - EventType type = 1; - // kv holds the KeyValue for the event. - // A PUT event contains current kv pair. - // A PUT event with kv.Version=1 indicates the creation of a key. - // A DELETE/EXPIRE event contains the deleted key with - // its modification revision set to the revision of deletion. - KeyValue kv = 2; - - // prev_kv holds the key-value pair before the event happens. - KeyValue prev_kv = 3; + enum EventType { + PUT = 0; + DELETE = 1; + } + // type is the kind of event. If type is a PUT, it indicates + // new data has been stored to the key. If type is a DELETE, + // it indicates the key was deleted. + EventType type = 1; + // kv holds the KeyValue for the event. + // A PUT event contains current kv pair. + // A PUT event with kv.Version=1 indicates the creation of a key. + // A DELETE/EXPIRE event contains the deleted key with + // its modification revision set to the revision of deletion. + KeyValue kv = 2; + + // prev_kv holds the key-value pair before the event happens. + KeyValue prev_kv = 3; } diff --git a/scripts/check.sh b/scripts/check.sh index c1568b810..63b205362 100755 --- a/scripts/check.sh +++ b/scripts/check.sh @@ -5,7 +5,7 @@ check_protoc_version() { major=$(echo ${version} | sed -n -e 's/.*\([0-9]\{1,\}\)\.[0-9]\{1,\}\.[0-9]\{1,\}.*/\1/p') minor=$(echo ${version} | sed -n -e 's/.*[0-9]\{1,\}\.\([0-9]\{1,\}\)\.[0-9]\{1,\}.*/\1/p') if [ "$major" -eq 3 ] && [ "$minor" -ge 8 ]; then - return 0 + return 0 fi echo "protoc version not match, version 3.8.x+ is needed, current version: ${version}" return 1 @@ -21,7 +21,7 @@ check-protos-compatible() { if [ ! -f "$GOPATH/bin/protolock" ]; then GO111MODULE=off go get github.com/nilslice/protolock/cmd/protolock - GO111MODULE=off go install github.com/nilslice/protolock/cmd/protolock + GO111MODULE=off go install github.com/nilslice/protolock/cmd/protolock fi if protolock status -lockdir=scripts -protoroot=proto; then diff --git a/scripts/proto.lock b/scripts/proto.lock index 8c09dc549..104d3bd76 100644 --- a/scripts/proto.lock +++ b/scripts/proto.lock @@ -12012,6 +12012,52 @@ } ] }, + { + "name": "DeleteRequest", + "fields": [ + { + "id": 1, + "name": "header", + "type": "RequestHeader" + }, + { + "id": 2, + "name": "key", + "type": "bytes" + }, + { + "id": 3, + "name": "range_end", + "type": "bytes" + }, + { + "id": 4, + "name": "prev_kv", + "type": "bool" + } + ] + }, + { + "name": "DeleteResponse", + "fields": [ + { + "id": 1, + "name": "header", + "type": "ResponseHeader" + }, + { + "id": 2, + "name": "deleted", + "type": "int64" + }, + { + "id": 3, + "name": "prev_kvs", + "type": "KeyValue", + "is_repeated": true + } + ] + }, { "name": "KeyValue", "fields": [ @@ -12087,6 +12133,11 @@ "name": "Put", "in_type": "PutRequest", "out_type": "PutResponse" + }, + { + "name": "Delete", + "in_type": "DeleteRequest", + "out_type": "DeleteResponse" } ] } From df7de980806772de855a6abd7ee64a770389ad4e Mon Sep 17 00:00:00 2001 From: lance6716 Date: Fri, 23 Feb 2024 16:16:09 +0800 Subject: [PATCH 2/2] fix git conflict Signed-off-by: lance6716 --- scripts/check.sh | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/scripts/check.sh b/scripts/check.sh index 574624ee3..0218df5d8 100755 --- a/scripts/check.sh +++ b/scripts/check.sh @@ -20,15 +20,7 @@ check-protos-compatible() { export PATH=$GOPATH/bin:$PATH if [ ! -f "$GOPATH/bin/protolock" ]; then -<<<<<<< HEAD - GO111MODULE=off go install github.com/nilslice/protolock/cmd/protolock@v0.17.0 -||||||| a554af8 - GO111MODULE=off go get github.com/nilslice/protolock/cmd/protolock - GO111MODULE=off go install github.com/nilslice/protolock/cmd/protolock -======= - GO111MODULE=off go get github.com/nilslice/protolock/cmd/protolock - GO111MODULE=off go install github.com/nilslice/protolock/cmd/protolock ->>>>>>> 881fcbf5bc41a492d77db7a27f07ffe5088df6dc + GO111MODULE=off go install github.com/nilslice/protolock/cmd/protolock@v0.17.0 fi if protolock status -lockdir=scripts -protoroot=proto; then