From 2295fbcf40ca6e03b8792dde0fa5d2112af764db Mon Sep 17 00:00:00 2001 From: bandl <1658002533@qq.com> Date: Thu, 21 Oct 2021 15:57:31 +0800 Subject: [PATCH 01/18] chore(proto): update proto --- pkg/proto/listx.pb.go | 1471 +++++++++++++++++++++++++++++++ pkg/proto/storage.pb.go | 614 +++++++++++-- pkg/structure/const.gen.go | 37 + pkg/structure/generate/tem.yaml | 16 +- protobuf/listx.proto | 87 ++ protobuf/storage.proto | 13 + 6 files changed, 2186 insertions(+), 52 deletions(-) create mode 100644 pkg/proto/listx.pb.go create mode 100644 protobuf/listx.proto diff --git a/pkg/proto/listx.pb.go b/pkg/proto/listx.pb.go new file mode 100644 index 0000000..160ceee --- /dev/null +++ b/pkg/proto/listx.pb.go @@ -0,0 +1,1471 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.26.0 +// protoc v3.17.3 +// source: listx.proto + +package proto + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type LindexRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Key *BaseKey `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` +} + +func (x *LindexRequest) Reset() { + *x = LindexRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_listx_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *LindexRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LindexRequest) ProtoMessage() {} + +func (x *LindexRequest) ProtoReflect() protoreflect.Message { + mi := &file_listx_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LindexRequest.ProtoReflect.Descriptor instead. +func (*LindexRequest) Descriptor() ([]byte, []int) { + return file_listx_proto_rawDescGZIP(), []int{0} +} + +func (x *LindexRequest) GetKey() *BaseKey { + if x != nil { + return x.Key + } + return nil +} + +type LindexResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *LindexResponse) Reset() { + *x = LindexResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_listx_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *LindexResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LindexResponse) ProtoMessage() {} + +func (x *LindexResponse) ProtoReflect() protoreflect.Message { + mi := &file_listx_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LindexResponse.ProtoReflect.Descriptor instead. +func (*LindexResponse) Descriptor() ([]byte, []int) { + return file_listx_proto_rawDescGZIP(), []int{1} +} + +type LlenRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Key *BaseKey `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` +} + +func (x *LlenRequest) Reset() { + *x = LlenRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_listx_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *LlenRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LlenRequest) ProtoMessage() {} + +func (x *LlenRequest) ProtoReflect() protoreflect.Message { + mi := &file_listx_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LlenRequest.ProtoReflect.Descriptor instead. +func (*LlenRequest) Descriptor() ([]byte, []int) { + return file_listx_proto_rawDescGZIP(), []int{2} +} + +func (x *LlenRequest) GetKey() *BaseKey { + if x != nil { + return x.Key + } + return nil +} + +type LlenResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *LlenResponse) Reset() { + *x = LlenResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_listx_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *LlenResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LlenResponse) ProtoMessage() {} + +func (x *LlenResponse) ProtoReflect() protoreflect.Message { + mi := &file_listx_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LlenResponse.ProtoReflect.Descriptor instead. +func (*LlenResponse) Descriptor() ([]byte, []int) { + return file_listx_proto_rawDescGZIP(), []int{3} +} + +type LpopRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Key *BaseKey `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` +} + +func (x *LpopRequest) Reset() { + *x = LpopRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_listx_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *LpopRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LpopRequest) ProtoMessage() {} + +func (x *LpopRequest) ProtoReflect() protoreflect.Message { + mi := &file_listx_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LpopRequest.ProtoReflect.Descriptor instead. +func (*LpopRequest) Descriptor() ([]byte, []int) { + return file_listx_proto_rawDescGZIP(), []int{4} +} + +func (x *LpopRequest) GetKey() *BaseKey { + if x != nil { + return x.Key + } + return nil +} + +type LpopResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *LpopResponse) Reset() { + *x = LpopResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_listx_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *LpopResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LpopResponse) ProtoMessage() {} + +func (x *LpopResponse) ProtoReflect() protoreflect.Message { + mi := &file_listx_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LpopResponse.ProtoReflect.Descriptor instead. +func (*LpopResponse) Descriptor() ([]byte, []int) { + return file_listx_proto_rawDescGZIP(), []int{5} +} + +type LpushRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Key *BaseKey `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` +} + +func (x *LpushRequest) Reset() { + *x = LpushRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_listx_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *LpushRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LpushRequest) ProtoMessage() {} + +func (x *LpushRequest) ProtoReflect() protoreflect.Message { + mi := &file_listx_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LpushRequest.ProtoReflect.Descriptor instead. +func (*LpushRequest) Descriptor() ([]byte, []int) { + return file_listx_proto_rawDescGZIP(), []int{6} +} + +func (x *LpushRequest) GetKey() *BaseKey { + if x != nil { + return x.Key + } + return nil +} + +type LpushResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *LpushResponse) Reset() { + *x = LpushResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_listx_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *LpushResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LpushResponse) ProtoMessage() {} + +func (x *LpushResponse) ProtoReflect() protoreflect.Message { + mi := &file_listx_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LpushResponse.ProtoReflect.Descriptor instead. +func (*LpushResponse) Descriptor() ([]byte, []int) { + return file_listx_proto_rawDescGZIP(), []int{7} +} + +type LpushxRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Key *BaseKey `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` +} + +func (x *LpushxRequest) Reset() { + *x = LpushxRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_listx_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *LpushxRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LpushxRequest) ProtoMessage() {} + +func (x *LpushxRequest) ProtoReflect() protoreflect.Message { + mi := &file_listx_proto_msgTypes[8] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LpushxRequest.ProtoReflect.Descriptor instead. +func (*LpushxRequest) Descriptor() ([]byte, []int) { + return file_listx_proto_rawDescGZIP(), []int{8} +} + +func (x *LpushxRequest) GetKey() *BaseKey { + if x != nil { + return x.Key + } + return nil +} + +type LpushxResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *LpushxResponse) Reset() { + *x = LpushxResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_listx_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *LpushxResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LpushxResponse) ProtoMessage() {} + +func (x *LpushxResponse) ProtoReflect() protoreflect.Message { + mi := &file_listx_proto_msgTypes[9] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LpushxResponse.ProtoReflect.Descriptor instead. +func (*LpushxResponse) Descriptor() ([]byte, []int) { + return file_listx_proto_rawDescGZIP(), []int{9} +} + +type LrangeRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Key *BaseKey `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` +} + +func (x *LrangeRequest) Reset() { + *x = LrangeRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_listx_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *LrangeRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LrangeRequest) ProtoMessage() {} + +func (x *LrangeRequest) ProtoReflect() protoreflect.Message { + mi := &file_listx_proto_msgTypes[10] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LrangeRequest.ProtoReflect.Descriptor instead. +func (*LrangeRequest) Descriptor() ([]byte, []int) { + return file_listx_proto_rawDescGZIP(), []int{10} +} + +func (x *LrangeRequest) GetKey() *BaseKey { + if x != nil { + return x.Key + } + return nil +} + +type LrangeResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *LrangeResponse) Reset() { + *x = LrangeResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_listx_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *LrangeResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LrangeResponse) ProtoMessage() {} + +func (x *LrangeResponse) ProtoReflect() protoreflect.Message { + mi := &file_listx_proto_msgTypes[11] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LrangeResponse.ProtoReflect.Descriptor instead. +func (*LrangeResponse) Descriptor() ([]byte, []int) { + return file_listx_proto_rawDescGZIP(), []int{11} +} + +type LremRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Key *BaseKey `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` +} + +func (x *LremRequest) Reset() { + *x = LremRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_listx_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *LremRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LremRequest) ProtoMessage() {} + +func (x *LremRequest) ProtoReflect() protoreflect.Message { + mi := &file_listx_proto_msgTypes[12] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LremRequest.ProtoReflect.Descriptor instead. +func (*LremRequest) Descriptor() ([]byte, []int) { + return file_listx_proto_rawDescGZIP(), []int{12} +} + +func (x *LremRequest) GetKey() *BaseKey { + if x != nil { + return x.Key + } + return nil +} + +type LremResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *LremResponse) Reset() { + *x = LremResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_listx_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *LremResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LremResponse) ProtoMessage() {} + +func (x *LremResponse) ProtoReflect() protoreflect.Message { + mi := &file_listx_proto_msgTypes[13] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LremResponse.ProtoReflect.Descriptor instead. +func (*LremResponse) Descriptor() ([]byte, []int) { + return file_listx_proto_rawDescGZIP(), []int{13} +} + +type LsetRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Key *BaseKey `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` +} + +func (x *LsetRequest) Reset() { + *x = LsetRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_listx_proto_msgTypes[14] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *LsetRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LsetRequest) ProtoMessage() {} + +func (x *LsetRequest) ProtoReflect() protoreflect.Message { + mi := &file_listx_proto_msgTypes[14] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LsetRequest.ProtoReflect.Descriptor instead. +func (*LsetRequest) Descriptor() ([]byte, []int) { + return file_listx_proto_rawDescGZIP(), []int{14} +} + +func (x *LsetRequest) GetKey() *BaseKey { + if x != nil { + return x.Key + } + return nil +} + +type LsetResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *LsetResponse) Reset() { + *x = LsetResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_listx_proto_msgTypes[15] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *LsetResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LsetResponse) ProtoMessage() {} + +func (x *LsetResponse) ProtoReflect() protoreflect.Message { + mi := &file_listx_proto_msgTypes[15] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LsetResponse.ProtoReflect.Descriptor instead. +func (*LsetResponse) Descriptor() ([]byte, []int) { + return file_listx_proto_rawDescGZIP(), []int{15} +} + +type RpopRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Key *BaseKey `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` +} + +func (x *RpopRequest) Reset() { + *x = RpopRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_listx_proto_msgTypes[16] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RpopRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RpopRequest) ProtoMessage() {} + +func (x *RpopRequest) ProtoReflect() protoreflect.Message { + mi := &file_listx_proto_msgTypes[16] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RpopRequest.ProtoReflect.Descriptor instead. +func (*RpopRequest) Descriptor() ([]byte, []int) { + return file_listx_proto_rawDescGZIP(), []int{16} +} + +func (x *RpopRequest) GetKey() *BaseKey { + if x != nil { + return x.Key + } + return nil +} + +type RpopResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *RpopResponse) Reset() { + *x = RpopResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_listx_proto_msgTypes[17] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RpopResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RpopResponse) ProtoMessage() {} + +func (x *RpopResponse) ProtoReflect() protoreflect.Message { + mi := &file_listx_proto_msgTypes[17] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RpopResponse.ProtoReflect.Descriptor instead. +func (*RpopResponse) Descriptor() ([]byte, []int) { + return file_listx_proto_rawDescGZIP(), []int{17} +} + +type LtrimRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Key *BaseKey `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` +} + +func (x *LtrimRequest) Reset() { + *x = LtrimRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_listx_proto_msgTypes[18] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *LtrimRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LtrimRequest) ProtoMessage() {} + +func (x *LtrimRequest) ProtoReflect() protoreflect.Message { + mi := &file_listx_proto_msgTypes[18] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LtrimRequest.ProtoReflect.Descriptor instead. +func (*LtrimRequest) Descriptor() ([]byte, []int) { + return file_listx_proto_rawDescGZIP(), []int{18} +} + +func (x *LtrimRequest) GetKey() *BaseKey { + if x != nil { + return x.Key + } + return nil +} + +type LtrimResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *LtrimResponse) Reset() { + *x = LtrimResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_listx_proto_msgTypes[19] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *LtrimResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LtrimResponse) ProtoMessage() {} + +func (x *LtrimResponse) ProtoReflect() protoreflect.Message { + mi := &file_listx_proto_msgTypes[19] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LtrimResponse.ProtoReflect.Descriptor instead. +func (*LtrimResponse) Descriptor() ([]byte, []int) { + return file_listx_proto_rawDescGZIP(), []int{19} +} + +type RpushRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Key *BaseKey `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` +} + +func (x *RpushRequest) Reset() { + *x = RpushRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_listx_proto_msgTypes[20] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RpushRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RpushRequest) ProtoMessage() {} + +func (x *RpushRequest) ProtoReflect() protoreflect.Message { + mi := &file_listx_proto_msgTypes[20] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RpushRequest.ProtoReflect.Descriptor instead. +func (*RpushRequest) Descriptor() ([]byte, []int) { + return file_listx_proto_rawDescGZIP(), []int{20} +} + +func (x *RpushRequest) GetKey() *BaseKey { + if x != nil { + return x.Key + } + return nil +} + +type RpushResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *RpushResponse) Reset() { + *x = RpushResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_listx_proto_msgTypes[21] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RpushResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RpushResponse) ProtoMessage() {} + +func (x *RpushResponse) ProtoReflect() protoreflect.Message { + mi := &file_listx_proto_msgTypes[21] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RpushResponse.ProtoReflect.Descriptor instead. +func (*RpushResponse) Descriptor() ([]byte, []int) { + return file_listx_proto_rawDescGZIP(), []int{21} +} + +type RpushxRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Key *BaseKey `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` +} + +func (x *RpushxRequest) Reset() { + *x = RpushxRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_listx_proto_msgTypes[22] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RpushxRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RpushxRequest) ProtoMessage() {} + +func (x *RpushxRequest) ProtoReflect() protoreflect.Message { + mi := &file_listx_proto_msgTypes[22] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RpushxRequest.ProtoReflect.Descriptor instead. +func (*RpushxRequest) Descriptor() ([]byte, []int) { + return file_listx_proto_rawDescGZIP(), []int{22} +} + +func (x *RpushxRequest) GetKey() *BaseKey { + if x != nil { + return x.Key + } + return nil +} + +type RpushxResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *RpushxResponse) Reset() { + *x = RpushxResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_listx_proto_msgTypes[23] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RpushxResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RpushxResponse) ProtoMessage() {} + +func (x *RpushxResponse) ProtoReflect() protoreflect.Message { + mi := &file_listx_proto_msgTypes[23] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RpushxResponse.ProtoReflect.Descriptor instead. +func (*RpushxResponse) Descriptor() ([]byte, []int) { + return file_listx_proto_rawDescGZIP(), []int{23} +} + +var File_listx_proto protoreflect.FileDescriptor + +var file_listx_proto_rawDesc = []byte{ + 0x0a, 0x0b, 0x6c, 0x69, 0x73, 0x74, 0x78, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0a, 0x62, + 0x61, 0x73, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x2b, 0x0a, 0x0d, 0x4c, 0x69, 0x6e, + 0x64, 0x65, 0x78, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x03, 0x6b, 0x65, + 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x4b, 0x65, + 0x79, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x22, 0x10, 0x0a, 0x0e, 0x4c, 0x69, 0x6e, 0x64, 0x65, 0x78, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x29, 0x0a, 0x0b, 0x4c, 0x6c, 0x65, 0x6e, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x4b, 0x65, 0x79, 0x52, 0x03, + 0x6b, 0x65, 0x79, 0x22, 0x0e, 0x0a, 0x0c, 0x4c, 0x6c, 0x65, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x29, 0x0a, 0x0b, 0x4c, 0x70, 0x6f, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x08, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x4b, 0x65, 0x79, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x22, 0x0e, + 0x0a, 0x0c, 0x4c, 0x70, 0x6f, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x2a, + 0x0a, 0x0c, 0x4c, 0x70, 0x75, 0x73, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, + 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x42, 0x61, + 0x73, 0x65, 0x4b, 0x65, 0x79, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x22, 0x0f, 0x0a, 0x0d, 0x4c, 0x70, + 0x75, 0x73, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x2b, 0x0a, 0x0d, 0x4c, + 0x70, 0x75, 0x73, 0x68, 0x78, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x03, + 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x42, 0x61, 0x73, 0x65, + 0x4b, 0x65, 0x79, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x22, 0x10, 0x0a, 0x0e, 0x4c, 0x70, 0x75, 0x73, + 0x68, 0x78, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x2b, 0x0a, 0x0d, 0x4c, 0x72, + 0x61, 0x6e, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x03, 0x6b, + 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x4b, + 0x65, 0x79, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x22, 0x10, 0x0a, 0x0e, 0x4c, 0x72, 0x61, 0x6e, 0x67, + 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x29, 0x0a, 0x0b, 0x4c, 0x72, 0x65, + 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x4b, 0x65, 0x79, 0x52, + 0x03, 0x6b, 0x65, 0x79, 0x22, 0x0e, 0x0a, 0x0c, 0x4c, 0x72, 0x65, 0x6d, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x29, 0x0a, 0x0b, 0x4c, 0x73, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x08, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x4b, 0x65, 0x79, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x22, + 0x0e, 0x0a, 0x0c, 0x4c, 0x73, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0x29, 0x0a, 0x0b, 0x52, 0x70, 0x6f, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, + 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x42, 0x61, + 0x73, 0x65, 0x4b, 0x65, 0x79, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x22, 0x0e, 0x0a, 0x0c, 0x52, 0x70, + 0x6f, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x2a, 0x0a, 0x0c, 0x4c, 0x74, + 0x72, 0x69, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x03, 0x6b, 0x65, + 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x4b, 0x65, + 0x79, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x22, 0x0f, 0x0a, 0x0d, 0x4c, 0x74, 0x72, 0x69, 0x6d, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x2a, 0x0a, 0x0c, 0x52, 0x70, 0x75, 0x73, 0x68, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x4b, 0x65, 0x79, 0x52, 0x03, + 0x6b, 0x65, 0x79, 0x22, 0x0f, 0x0a, 0x0d, 0x52, 0x70, 0x75, 0x73, 0x68, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x2b, 0x0a, 0x0d, 0x52, 0x70, 0x75, 0x73, 0x68, 0x78, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x4b, 0x65, 0x79, 0x52, 0x03, 0x6b, 0x65, + 0x79, 0x22, 0x10, 0x0a, 0x0e, 0x52, 0x70, 0x75, 0x73, 0x68, 0x78, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x42, 0x0b, 0x5a, 0x09, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_listx_proto_rawDescOnce sync.Once + file_listx_proto_rawDescData = file_listx_proto_rawDesc +) + +func file_listx_proto_rawDescGZIP() []byte { + file_listx_proto_rawDescOnce.Do(func() { + file_listx_proto_rawDescData = protoimpl.X.CompressGZIP(file_listx_proto_rawDescData) + }) + return file_listx_proto_rawDescData +} + +var file_listx_proto_msgTypes = make([]protoimpl.MessageInfo, 24) +var file_listx_proto_goTypes = []interface{}{ + (*LindexRequest)(nil), // 0: LindexRequest + (*LindexResponse)(nil), // 1: LindexResponse + (*LlenRequest)(nil), // 2: LlenRequest + (*LlenResponse)(nil), // 3: LlenResponse + (*LpopRequest)(nil), // 4: LpopRequest + (*LpopResponse)(nil), // 5: LpopResponse + (*LpushRequest)(nil), // 6: LpushRequest + (*LpushResponse)(nil), // 7: LpushResponse + (*LpushxRequest)(nil), // 8: LpushxRequest + (*LpushxResponse)(nil), // 9: LpushxResponse + (*LrangeRequest)(nil), // 10: LrangeRequest + (*LrangeResponse)(nil), // 11: LrangeResponse + (*LremRequest)(nil), // 12: LremRequest + (*LremResponse)(nil), // 13: LremResponse + (*LsetRequest)(nil), // 14: LsetRequest + (*LsetResponse)(nil), // 15: LsetResponse + (*RpopRequest)(nil), // 16: RpopRequest + (*RpopResponse)(nil), // 17: RpopResponse + (*LtrimRequest)(nil), // 18: LtrimRequest + (*LtrimResponse)(nil), // 19: LtrimResponse + (*RpushRequest)(nil), // 20: RpushRequest + (*RpushResponse)(nil), // 21: RpushResponse + (*RpushxRequest)(nil), // 22: RpushxRequest + (*RpushxResponse)(nil), // 23: RpushxResponse + (*BaseKey)(nil), // 24: BaseKey +} +var file_listx_proto_depIdxs = []int32{ + 24, // 0: LindexRequest.key:type_name -> BaseKey + 24, // 1: LlenRequest.key:type_name -> BaseKey + 24, // 2: LpopRequest.key:type_name -> BaseKey + 24, // 3: LpushRequest.key:type_name -> BaseKey + 24, // 4: LpushxRequest.key:type_name -> BaseKey + 24, // 5: LrangeRequest.key:type_name -> BaseKey + 24, // 6: LremRequest.key:type_name -> BaseKey + 24, // 7: LsetRequest.key:type_name -> BaseKey + 24, // 8: RpopRequest.key:type_name -> BaseKey + 24, // 9: LtrimRequest.key:type_name -> BaseKey + 24, // 10: RpushRequest.key:type_name -> BaseKey + 24, // 11: RpushxRequest.key:type_name -> BaseKey + 12, // [12:12] is the sub-list for method output_type + 12, // [12:12] is the sub-list for method input_type + 12, // [12:12] is the sub-list for extension type_name + 12, // [12:12] is the sub-list for extension extendee + 0, // [0:12] is the sub-list for field type_name +} + +func init() { file_listx_proto_init() } +func file_listx_proto_init() { + if File_listx_proto != nil { + return + } + file_base_proto_init() + if !protoimpl.UnsafeEnabled { + file_listx_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LindexRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_listx_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LindexResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_listx_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LlenRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_listx_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LlenResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_listx_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LpopRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_listx_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LpopResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_listx_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LpushRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_listx_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LpushResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_listx_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LpushxRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_listx_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LpushxResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_listx_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LrangeRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_listx_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LrangeResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_listx_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LremRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_listx_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LremResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_listx_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LsetRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_listx_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LsetResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_listx_proto_msgTypes[16].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RpopRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_listx_proto_msgTypes[17].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RpopResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_listx_proto_msgTypes[18].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LtrimRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_listx_proto_msgTypes[19].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LtrimResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_listx_proto_msgTypes[20].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RpushRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_listx_proto_msgTypes[21].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RpushResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_listx_proto_msgTypes[22].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RpushxRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_listx_proto_msgTypes[23].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RpushxResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_listx_proto_rawDesc, + NumEnums: 0, + NumMessages: 24, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_listx_proto_goTypes, + DependencyIndexes: file_listx_proto_depIdxs, + MessageInfos: file_listx_proto_msgTypes, + }.Build() + File_listx_proto = out.File + file_listx_proto_rawDesc = nil + file_listx_proto_goTypes = nil + file_listx_proto_depIdxs = nil +} diff --git a/pkg/proto/storage.pb.go b/pkg/proto/storage.pb.go index 7ae6952..0d11d44 100644 --- a/pkg/proto/storage.pb.go +++ b/pkg/proto/storage.pb.go @@ -30,35 +30,66 @@ var File_storage_proto protoreflect.FileDescriptor var file_storage_proto_rawDesc = []byte{ 0x0a, 0x0d, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, - 0x0d, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x78, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0xa2, - 0x03, 0x0a, 0x0a, 0x43, 0x6f, 0x6d, 0x6d, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x20, 0x0a, - 0x03, 0x53, 0x65, 0x74, 0x12, 0x0b, 0x2e, 0x53, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x0c, 0x2e, 0x53, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, - 0x20, 0x0a, 0x03, 0x47, 0x65, 0x74, 0x12, 0x0b, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x0c, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x12, 0x20, 0x0a, 0x03, 0x41, 0x64, 0x64, 0x12, 0x0b, 0x2e, 0x41, 0x64, 0x64, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0c, 0x2e, 0x41, 0x64, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x29, 0x0a, 0x06, 0x52, 0x65, 0x64, 0x75, 0x63, 0x65, 0x12, 0x0e, 0x2e, - 0x52, 0x65, 0x64, 0x75, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0f, 0x2e, - 0x52, 0x65, 0x64, 0x75, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x29, - 0x0a, 0x06, 0x53, 0x65, 0x74, 0x62, 0x69, 0x74, 0x12, 0x0e, 0x2e, 0x53, 0x65, 0x74, 0x62, 0x69, - 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0f, 0x2e, 0x53, 0x65, 0x74, 0x62, 0x69, - 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x29, 0x0a, 0x06, 0x47, 0x65, 0x74, - 0x62, 0x69, 0x74, 0x12, 0x0e, 0x2e, 0x47, 0x65, 0x74, 0x62, 0x69, 0x74, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x0f, 0x2e, 0x47, 0x65, 0x74, 0x62, 0x69, 0x74, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2f, 0x0a, 0x08, 0x47, 0x65, 0x74, 0x72, 0x61, 0x6e, 0x67, 0x65, - 0x12, 0x10, 0x2e, 0x47, 0x65, 0x74, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x47, 0x65, 0x74, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x29, 0x0a, 0x06, 0x47, 0x65, 0x74, 0x73, 0x65, 0x74, 0x12, - 0x0e, 0x2e, 0x47, 0x65, 0x74, 0x73, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x0f, 0x2e, 0x47, 0x65, 0x74, 0x73, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x29, 0x0a, 0x06, 0x53, 0x74, 0x72, 0x6c, 0x65, 0x6e, 0x12, 0x0e, 0x2e, 0x53, 0x74, 0x72, - 0x6c, 0x65, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0f, 0x2e, 0x53, 0x74, 0x72, - 0x6c, 0x65, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x26, 0x0a, 0x05, 0x53, - 0x65, 0x74, 0x6e, 0x78, 0x12, 0x0d, 0x2e, 0x53, 0x65, 0x74, 0x6e, 0x78, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x0e, 0x2e, 0x53, 0x65, 0x74, 0x6e, 0x78, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x42, 0x0b, 0x5a, 0x09, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x0d, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x78, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0b, + 0x6c, 0x69, 0x73, 0x74, 0x78, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0xff, 0x06, 0x0a, 0x0a, + 0x43, 0x6f, 0x6d, 0x6d, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x20, 0x0a, 0x03, 0x53, 0x65, + 0x74, 0x12, 0x0b, 0x2e, 0x53, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0c, + 0x2e, 0x53, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x20, 0x0a, 0x03, + 0x47, 0x65, 0x74, 0x12, 0x0b, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x0c, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x20, + 0x0a, 0x03, 0x41, 0x64, 0x64, 0x12, 0x0b, 0x2e, 0x41, 0x64, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x0c, 0x2e, 0x41, 0x64, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x29, 0x0a, 0x06, 0x52, 0x65, 0x64, 0x75, 0x63, 0x65, 0x12, 0x0e, 0x2e, 0x52, 0x65, 0x64, + 0x75, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0f, 0x2e, 0x52, 0x65, 0x64, + 0x75, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x29, 0x0a, 0x06, 0x53, + 0x65, 0x74, 0x62, 0x69, 0x74, 0x12, 0x0e, 0x2e, 0x53, 0x65, 0x74, 0x62, 0x69, 0x74, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0f, 0x2e, 0x53, 0x65, 0x74, 0x62, 0x69, 0x74, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x29, 0x0a, 0x06, 0x47, 0x65, 0x74, 0x62, 0x69, 0x74, + 0x12, 0x0e, 0x2e, 0x47, 0x65, 0x74, 0x62, 0x69, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x0f, 0x2e, 0x47, 0x65, 0x74, 0x62, 0x69, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x2f, 0x0a, 0x08, 0x47, 0x65, 0x74, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x10, 0x2e, + 0x47, 0x65, 0x74, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x11, 0x2e, 0x47, 0x65, 0x74, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x29, 0x0a, 0x06, 0x47, 0x65, 0x74, 0x73, 0x65, 0x74, 0x12, 0x0e, 0x2e, 0x47, + 0x65, 0x74, 0x73, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0f, 0x2e, 0x47, + 0x65, 0x74, 0x73, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x29, 0x0a, + 0x06, 0x53, 0x74, 0x72, 0x6c, 0x65, 0x6e, 0x12, 0x0e, 0x2e, 0x53, 0x74, 0x72, 0x6c, 0x65, 0x6e, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0f, 0x2e, 0x53, 0x74, 0x72, 0x6c, 0x65, 0x6e, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x26, 0x0a, 0x05, 0x53, 0x65, 0x74, 0x6e, + 0x78, 0x12, 0x0d, 0x2e, 0x53, 0x65, 0x74, 0x6e, 0x78, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x0e, 0x2e, 0x53, 0x65, 0x74, 0x6e, 0x78, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x29, 0x0a, 0x06, 0x4c, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x0e, 0x2e, 0x4c, 0x69, 0x6e, + 0x64, 0x65, 0x78, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0f, 0x2e, 0x4c, 0x69, 0x6e, + 0x64, 0x65, 0x78, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x23, 0x0a, 0x04, 0x4c, + 0x6c, 0x65, 0x6e, 0x12, 0x0c, 0x2e, 0x4c, 0x6c, 0x65, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x0d, 0x2e, 0x4c, 0x6c, 0x65, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x23, 0x0a, 0x04, 0x4c, 0x70, 0x6f, 0x70, 0x12, 0x0c, 0x2e, 0x4c, 0x70, 0x6f, 0x70, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0d, 0x2e, 0x4c, 0x70, 0x6f, 0x70, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x26, 0x0a, 0x05, 0x4c, 0x70, 0x75, 0x73, 0x68, 0x12, 0x0d, + 0x2e, 0x4c, 0x70, 0x75, 0x73, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0e, 0x2e, + 0x4c, 0x70, 0x75, 0x73, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x29, 0x0a, + 0x06, 0x4c, 0x70, 0x75, 0x73, 0x68, 0x78, 0x12, 0x0e, 0x2e, 0x4c, 0x70, 0x75, 0x73, 0x68, 0x78, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0f, 0x2e, 0x4c, 0x70, 0x75, 0x73, 0x68, 0x78, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x29, 0x0a, 0x06, 0x4c, 0x72, 0x61, 0x6e, + 0x67, 0x65, 0x12, 0x0e, 0x2e, 0x4c, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x0f, 0x2e, 0x4c, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x23, 0x0a, 0x04, 0x4c, 0x72, 0x65, 0x6d, 0x12, 0x0c, 0x2e, 0x4c, 0x72, + 0x65, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0d, 0x2e, 0x4c, 0x72, 0x65, 0x6d, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x23, 0x0a, 0x04, 0x4c, 0x73, 0x65, 0x74, + 0x12, 0x0c, 0x2e, 0x4c, 0x73, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0d, + 0x2e, 0x4c, 0x73, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x23, 0x0a, + 0x04, 0x52, 0x70, 0x6f, 0x70, 0x12, 0x0c, 0x2e, 0x52, 0x70, 0x6f, 0x70, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x0d, 0x2e, 0x52, 0x70, 0x6f, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x26, 0x0a, 0x05, 0x4c, 0x74, 0x72, 0x69, 0x6d, 0x12, 0x0d, 0x2e, 0x4c, 0x74, + 0x72, 0x69, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0e, 0x2e, 0x4c, 0x74, 0x72, + 0x69, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x26, 0x0a, 0x05, 0x52, 0x70, + 0x75, 0x73, 0x68, 0x12, 0x0d, 0x2e, 0x52, 0x70, 0x75, 0x73, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x0e, 0x2e, 0x52, 0x70, 0x75, 0x73, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x29, 0x0a, 0x06, 0x52, 0x70, 0x75, 0x73, 0x68, 0x78, 0x12, 0x0e, 0x2e, 0x52, + 0x70, 0x75, 0x73, 0x68, 0x78, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0f, 0x2e, 0x52, + 0x70, 0x75, 0x73, 0x68, 0x78, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x0b, 0x5a, + 0x09, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var file_storage_proto_goTypes = []interface{}{ @@ -72,16 +103,40 @@ var file_storage_proto_goTypes = []interface{}{ (*GetsetRequest)(nil), // 7: GetsetRequest (*StrlenRequest)(nil), // 8: StrlenRequest (*SetnxRequest)(nil), // 9: SetnxRequest - (*SetResponse)(nil), // 10: SetResponse - (*GetResponse)(nil), // 11: GetResponse - (*AddResponse)(nil), // 12: AddResponse - (*ReduceResponse)(nil), // 13: ReduceResponse - (*SetbitResponse)(nil), // 14: SetbitResponse - (*GetbitResponse)(nil), // 15: GetbitResponse - (*GetrangeResponse)(nil), // 16: GetrangeResponse - (*GetsetResponse)(nil), // 17: GetsetResponse - (*StrlenResponse)(nil), // 18: StrlenResponse - (*SetnxResponse)(nil), // 19: SetnxResponse + (*LindexRequest)(nil), // 10: LindexRequest + (*LlenRequest)(nil), // 11: LlenRequest + (*LpopRequest)(nil), // 12: LpopRequest + (*LpushRequest)(nil), // 13: LpushRequest + (*LpushxRequest)(nil), // 14: LpushxRequest + (*LrangeRequest)(nil), // 15: LrangeRequest + (*LremRequest)(nil), // 16: LremRequest + (*LsetRequest)(nil), // 17: LsetRequest + (*RpopRequest)(nil), // 18: RpopRequest + (*LtrimRequest)(nil), // 19: LtrimRequest + (*RpushRequest)(nil), // 20: RpushRequest + (*RpushxRequest)(nil), // 21: RpushxRequest + (*SetResponse)(nil), // 22: SetResponse + (*GetResponse)(nil), // 23: GetResponse + (*AddResponse)(nil), // 24: AddResponse + (*ReduceResponse)(nil), // 25: ReduceResponse + (*SetbitResponse)(nil), // 26: SetbitResponse + (*GetbitResponse)(nil), // 27: GetbitResponse + (*GetrangeResponse)(nil), // 28: GetrangeResponse + (*GetsetResponse)(nil), // 29: GetsetResponse + (*StrlenResponse)(nil), // 30: StrlenResponse + (*SetnxResponse)(nil), // 31: SetnxResponse + (*LindexResponse)(nil), // 32: LindexResponse + (*LlenResponse)(nil), // 33: LlenResponse + (*LpopResponse)(nil), // 34: LpopResponse + (*LpushResponse)(nil), // 35: LpushResponse + (*LpushxResponse)(nil), // 36: LpushxResponse + (*LrangeResponse)(nil), // 37: LrangeResponse + (*LremResponse)(nil), // 38: LremResponse + (*LsetResponse)(nil), // 39: LsetResponse + (*RpopResponse)(nil), // 40: RpopResponse + (*LtrimResponse)(nil), // 41: LtrimResponse + (*RpushResponse)(nil), // 42: RpushResponse + (*RpushxResponse)(nil), // 43: RpushxResponse } var file_storage_proto_depIdxs = []int32{ 0, // 0: CommServer.Set:input_type -> SetRequest @@ -94,18 +149,42 @@ var file_storage_proto_depIdxs = []int32{ 7, // 7: CommServer.Getset:input_type -> GetsetRequest 8, // 8: CommServer.Strlen:input_type -> StrlenRequest 9, // 9: CommServer.Setnx:input_type -> SetnxRequest - 10, // 10: CommServer.Set:output_type -> SetResponse - 11, // 11: CommServer.Get:output_type -> GetResponse - 12, // 12: CommServer.Add:output_type -> AddResponse - 13, // 13: CommServer.Reduce:output_type -> ReduceResponse - 14, // 14: CommServer.Setbit:output_type -> SetbitResponse - 15, // 15: CommServer.Getbit:output_type -> GetbitResponse - 16, // 16: CommServer.Getrange:output_type -> GetrangeResponse - 17, // 17: CommServer.Getset:output_type -> GetsetResponse - 18, // 18: CommServer.Strlen:output_type -> StrlenResponse - 19, // 19: CommServer.Setnx:output_type -> SetnxResponse - 10, // [10:20] is the sub-list for method output_type - 0, // [0:10] is the sub-list for method input_type + 10, // 10: CommServer.Lindex:input_type -> LindexRequest + 11, // 11: CommServer.Llen:input_type -> LlenRequest + 12, // 12: CommServer.Lpop:input_type -> LpopRequest + 13, // 13: CommServer.Lpush:input_type -> LpushRequest + 14, // 14: CommServer.Lpushx:input_type -> LpushxRequest + 15, // 15: CommServer.Lrange:input_type -> LrangeRequest + 16, // 16: CommServer.Lrem:input_type -> LremRequest + 17, // 17: CommServer.Lset:input_type -> LsetRequest + 18, // 18: CommServer.Rpop:input_type -> RpopRequest + 19, // 19: CommServer.Ltrim:input_type -> LtrimRequest + 20, // 20: CommServer.Rpush:input_type -> RpushRequest + 21, // 21: CommServer.Rpushx:input_type -> RpushxRequest + 22, // 22: CommServer.Set:output_type -> SetResponse + 23, // 23: CommServer.Get:output_type -> GetResponse + 24, // 24: CommServer.Add:output_type -> AddResponse + 25, // 25: CommServer.Reduce:output_type -> ReduceResponse + 26, // 26: CommServer.Setbit:output_type -> SetbitResponse + 27, // 27: CommServer.Getbit:output_type -> GetbitResponse + 28, // 28: CommServer.Getrange:output_type -> GetrangeResponse + 29, // 29: CommServer.Getset:output_type -> GetsetResponse + 30, // 30: CommServer.Strlen:output_type -> StrlenResponse + 31, // 31: CommServer.Setnx:output_type -> SetnxResponse + 32, // 32: CommServer.Lindex:output_type -> LindexResponse + 33, // 33: CommServer.Llen:output_type -> LlenResponse + 34, // 34: CommServer.Lpop:output_type -> LpopResponse + 35, // 35: CommServer.Lpush:output_type -> LpushResponse + 36, // 36: CommServer.Lpushx:output_type -> LpushxResponse + 37, // 37: CommServer.Lrange:output_type -> LrangeResponse + 38, // 38: CommServer.Lrem:output_type -> LremResponse + 39, // 39: CommServer.Lset:output_type -> LsetResponse + 40, // 40: CommServer.Rpop:output_type -> RpopResponse + 41, // 41: CommServer.Ltrim:output_type -> LtrimResponse + 42, // 42: CommServer.Rpush:output_type -> RpushResponse + 43, // 43: CommServer.Rpushx:output_type -> RpushxResponse + 22, // [22:44] is the sub-list for method output_type + 0, // [0:22] is the sub-list for method input_type 0, // [0:0] is the sub-list for extension type_name 0, // [0:0] is the sub-list for extension extendee 0, // [0:0] is the sub-list for field type_name @@ -117,6 +196,7 @@ func file_storage_proto_init() { return } file_stringx_proto_init() + file_listx_proto_init() type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ @@ -158,6 +238,18 @@ type CommServerClient interface { Getset(ctx context.Context, in *GetsetRequest, opts ...grpc.CallOption) (*GetsetResponse, error) Strlen(ctx context.Context, in *StrlenRequest, opts ...grpc.CallOption) (*StrlenResponse, error) Setnx(ctx context.Context, in *SetnxRequest, opts ...grpc.CallOption) (*SetnxResponse, error) + Lindex(ctx context.Context, in *LindexRequest, opts ...grpc.CallOption) (*LindexResponse, error) + Llen(ctx context.Context, in *LlenRequest, opts ...grpc.CallOption) (*LlenResponse, error) + Lpop(ctx context.Context, in *LpopRequest, opts ...grpc.CallOption) (*LpopResponse, error) + Lpush(ctx context.Context, in *LpushRequest, opts ...grpc.CallOption) (*LpushResponse, error) + Lpushx(ctx context.Context, in *LpushxRequest, opts ...grpc.CallOption) (*LpushxResponse, error) + Lrange(ctx context.Context, in *LrangeRequest, opts ...grpc.CallOption) (*LrangeResponse, error) + Lrem(ctx context.Context, in *LremRequest, opts ...grpc.CallOption) (*LremResponse, error) + Lset(ctx context.Context, in *LsetRequest, opts ...grpc.CallOption) (*LsetResponse, error) + Rpop(ctx context.Context, in *RpopRequest, opts ...grpc.CallOption) (*RpopResponse, error) + Ltrim(ctx context.Context, in *LtrimRequest, opts ...grpc.CallOption) (*LtrimResponse, error) + Rpush(ctx context.Context, in *RpushRequest, opts ...grpc.CallOption) (*RpushResponse, error) + Rpushx(ctx context.Context, in *RpushxRequest, opts ...grpc.CallOption) (*RpushxResponse, error) } type commServerClient struct { @@ -258,6 +350,114 @@ func (c *commServerClient) Setnx(ctx context.Context, in *SetnxRequest, opts ... return out, nil } +func (c *commServerClient) Lindex(ctx context.Context, in *LindexRequest, opts ...grpc.CallOption) (*LindexResponse, error) { + out := new(LindexResponse) + err := c.cc.Invoke(ctx, "/CommServer/Lindex", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *commServerClient) Llen(ctx context.Context, in *LlenRequest, opts ...grpc.CallOption) (*LlenResponse, error) { + out := new(LlenResponse) + err := c.cc.Invoke(ctx, "/CommServer/Llen", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *commServerClient) Lpop(ctx context.Context, in *LpopRequest, opts ...grpc.CallOption) (*LpopResponse, error) { + out := new(LpopResponse) + err := c.cc.Invoke(ctx, "/CommServer/Lpop", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *commServerClient) Lpush(ctx context.Context, in *LpushRequest, opts ...grpc.CallOption) (*LpushResponse, error) { + out := new(LpushResponse) + err := c.cc.Invoke(ctx, "/CommServer/Lpush", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *commServerClient) Lpushx(ctx context.Context, in *LpushxRequest, opts ...grpc.CallOption) (*LpushxResponse, error) { + out := new(LpushxResponse) + err := c.cc.Invoke(ctx, "/CommServer/Lpushx", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *commServerClient) Lrange(ctx context.Context, in *LrangeRequest, opts ...grpc.CallOption) (*LrangeResponse, error) { + out := new(LrangeResponse) + err := c.cc.Invoke(ctx, "/CommServer/Lrange", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *commServerClient) Lrem(ctx context.Context, in *LremRequest, opts ...grpc.CallOption) (*LremResponse, error) { + out := new(LremResponse) + err := c.cc.Invoke(ctx, "/CommServer/Lrem", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *commServerClient) Lset(ctx context.Context, in *LsetRequest, opts ...grpc.CallOption) (*LsetResponse, error) { + out := new(LsetResponse) + err := c.cc.Invoke(ctx, "/CommServer/Lset", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *commServerClient) Rpop(ctx context.Context, in *RpopRequest, opts ...grpc.CallOption) (*RpopResponse, error) { + out := new(RpopResponse) + err := c.cc.Invoke(ctx, "/CommServer/Rpop", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *commServerClient) Ltrim(ctx context.Context, in *LtrimRequest, opts ...grpc.CallOption) (*LtrimResponse, error) { + out := new(LtrimResponse) + err := c.cc.Invoke(ctx, "/CommServer/Ltrim", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *commServerClient) Rpush(ctx context.Context, in *RpushRequest, opts ...grpc.CallOption) (*RpushResponse, error) { + out := new(RpushResponse) + err := c.cc.Invoke(ctx, "/CommServer/Rpush", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *commServerClient) Rpushx(ctx context.Context, in *RpushxRequest, opts ...grpc.CallOption) (*RpushxResponse, error) { + out := new(RpushxResponse) + err := c.cc.Invoke(ctx, "/CommServer/Rpushx", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // CommServerServer is the server API for CommServer service. type CommServerServer interface { Set(context.Context, *SetRequest) (*SetResponse, error) @@ -270,6 +470,18 @@ type CommServerServer interface { Getset(context.Context, *GetsetRequest) (*GetsetResponse, error) Strlen(context.Context, *StrlenRequest) (*StrlenResponse, error) Setnx(context.Context, *SetnxRequest) (*SetnxResponse, error) + Lindex(context.Context, *LindexRequest) (*LindexResponse, error) + Llen(context.Context, *LlenRequest) (*LlenResponse, error) + Lpop(context.Context, *LpopRequest) (*LpopResponse, error) + Lpush(context.Context, *LpushRequest) (*LpushResponse, error) + Lpushx(context.Context, *LpushxRequest) (*LpushxResponse, error) + Lrange(context.Context, *LrangeRequest) (*LrangeResponse, error) + Lrem(context.Context, *LremRequest) (*LremResponse, error) + Lset(context.Context, *LsetRequest) (*LsetResponse, error) + Rpop(context.Context, *RpopRequest) (*RpopResponse, error) + Ltrim(context.Context, *LtrimRequest) (*LtrimResponse, error) + Rpush(context.Context, *RpushRequest) (*RpushResponse, error) + Rpushx(context.Context, *RpushxRequest) (*RpushxResponse, error) } // UnimplementedCommServerServer can be embedded to have forward compatible implementations. @@ -306,6 +518,42 @@ func (*UnimplementedCommServerServer) Strlen(context.Context, *StrlenRequest) (* func (*UnimplementedCommServerServer) Setnx(context.Context, *SetnxRequest) (*SetnxResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Setnx not implemented") } +func (*UnimplementedCommServerServer) Lindex(context.Context, *LindexRequest) (*LindexResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Lindex not implemented") +} +func (*UnimplementedCommServerServer) Llen(context.Context, *LlenRequest) (*LlenResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Llen not implemented") +} +func (*UnimplementedCommServerServer) Lpop(context.Context, *LpopRequest) (*LpopResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Lpop not implemented") +} +func (*UnimplementedCommServerServer) Lpush(context.Context, *LpushRequest) (*LpushResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Lpush not implemented") +} +func (*UnimplementedCommServerServer) Lpushx(context.Context, *LpushxRequest) (*LpushxResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Lpushx not implemented") +} +func (*UnimplementedCommServerServer) Lrange(context.Context, *LrangeRequest) (*LrangeResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Lrange not implemented") +} +func (*UnimplementedCommServerServer) Lrem(context.Context, *LremRequest) (*LremResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Lrem not implemented") +} +func (*UnimplementedCommServerServer) Lset(context.Context, *LsetRequest) (*LsetResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Lset not implemented") +} +func (*UnimplementedCommServerServer) Rpop(context.Context, *RpopRequest) (*RpopResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Rpop not implemented") +} +func (*UnimplementedCommServerServer) Ltrim(context.Context, *LtrimRequest) (*LtrimResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Ltrim not implemented") +} +func (*UnimplementedCommServerServer) Rpush(context.Context, *RpushRequest) (*RpushResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Rpush not implemented") +} +func (*UnimplementedCommServerServer) Rpushx(context.Context, *RpushxRequest) (*RpushxResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Rpushx not implemented") +} func RegisterCommServerServer(s *grpc.Server, srv CommServerServer) { s.RegisterService(&_CommServer_serviceDesc, srv) @@ -491,6 +739,222 @@ func _CommServer_Setnx_Handler(srv interface{}, ctx context.Context, dec func(in return interceptor(ctx, in, info, handler) } +func _CommServer_Lindex_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(LindexRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(CommServerServer).Lindex(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/CommServer/Lindex", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(CommServerServer).Lindex(ctx, req.(*LindexRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _CommServer_Llen_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(LlenRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(CommServerServer).Llen(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/CommServer/Llen", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(CommServerServer).Llen(ctx, req.(*LlenRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _CommServer_Lpop_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(LpopRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(CommServerServer).Lpop(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/CommServer/Lpop", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(CommServerServer).Lpop(ctx, req.(*LpopRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _CommServer_Lpush_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(LpushRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(CommServerServer).Lpush(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/CommServer/Lpush", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(CommServerServer).Lpush(ctx, req.(*LpushRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _CommServer_Lpushx_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(LpushxRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(CommServerServer).Lpushx(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/CommServer/Lpushx", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(CommServerServer).Lpushx(ctx, req.(*LpushxRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _CommServer_Lrange_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(LrangeRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(CommServerServer).Lrange(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/CommServer/Lrange", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(CommServerServer).Lrange(ctx, req.(*LrangeRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _CommServer_Lrem_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(LremRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(CommServerServer).Lrem(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/CommServer/Lrem", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(CommServerServer).Lrem(ctx, req.(*LremRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _CommServer_Lset_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(LsetRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(CommServerServer).Lset(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/CommServer/Lset", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(CommServerServer).Lset(ctx, req.(*LsetRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _CommServer_Rpop_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(RpopRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(CommServerServer).Rpop(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/CommServer/Rpop", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(CommServerServer).Rpop(ctx, req.(*RpopRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _CommServer_Ltrim_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(LtrimRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(CommServerServer).Ltrim(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/CommServer/Ltrim", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(CommServerServer).Ltrim(ctx, req.(*LtrimRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _CommServer_Rpush_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(RpushRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(CommServerServer).Rpush(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/CommServer/Rpush", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(CommServerServer).Rpush(ctx, req.(*RpushRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _CommServer_Rpushx_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(RpushxRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(CommServerServer).Rpushx(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/CommServer/Rpushx", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(CommServerServer).Rpushx(ctx, req.(*RpushxRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _CommServer_serviceDesc = grpc.ServiceDesc{ ServiceName: "CommServer", HandlerType: (*CommServerServer)(nil), @@ -535,6 +999,54 @@ var _CommServer_serviceDesc = grpc.ServiceDesc{ MethodName: "Setnx", Handler: _CommServer_Setnx_Handler, }, + { + MethodName: "Lindex", + Handler: _CommServer_Lindex_Handler, + }, + { + MethodName: "Llen", + Handler: _CommServer_Llen_Handler, + }, + { + MethodName: "Lpop", + Handler: _CommServer_Lpop_Handler, + }, + { + MethodName: "Lpush", + Handler: _CommServer_Lpush_Handler, + }, + { + MethodName: "Lpushx", + Handler: _CommServer_Lpushx_Handler, + }, + { + MethodName: "Lrange", + Handler: _CommServer_Lrange_Handler, + }, + { + MethodName: "Lrem", + Handler: _CommServer_Lrem_Handler, + }, + { + MethodName: "Lset", + Handler: _CommServer_Lset_Handler, + }, + { + MethodName: "Rpop", + Handler: _CommServer_Rpop_Handler, + }, + { + MethodName: "Ltrim", + Handler: _CommServer_Ltrim_Handler, + }, + { + MethodName: "Rpush", + Handler: _CommServer_Rpush_Handler, + }, + { + MethodName: "Rpushx", + Handler: _CommServer_Rpushx_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "storage.proto", diff --git a/pkg/structure/const.gen.go b/pkg/structure/const.gen.go index 76da0ab..b9555a1 100644 --- a/pkg/structure/const.gen.go +++ b/pkg/structure/const.gen.go @@ -7,6 +7,7 @@ const ( DEFAULT_KEY = iota STRING_X + LIST_X ) const ( @@ -21,6 +22,18 @@ const ( GETSET STRLEN SETNX + LINDEX + LLEN + LPOP + LPUSH + LPUSHX + LRANGE + LREM + LSET + RPOP + LTRIM + RPUSH + RPUSHX ) var CommKeyString = map[string]int{"set": STRING_X, @@ -33,6 +46,18 @@ var CommKeyString = map[string]int{"set": STRING_X, "getset": STRING_X, "strlen": STRING_X, "setnx": STRING_X, + "lindex": LIST_X, + "llen": LIST_X, + "lpop": LIST_X, + "lpush": LIST_X, + "lpushx": LIST_X, + "lrange": LIST_X, + "lrem": LIST_X, + "lset": LIST_X, + "rpop": LIST_X, + "ltrim": LIST_X, + "rpush": LIST_X, + "rpushx": LIST_X, } var CommKey = map[int]int{SET: STRING_X, @@ -45,4 +70,16 @@ var CommKey = map[int]int{SET: STRING_X, GETSET: STRING_X, STRLEN: STRING_X, SETNX: STRING_X, + LINDEX: LIST_X, + LLEN: LIST_X, + LPOP: LIST_X, + LPUSH: LIST_X, + LPUSHX: LIST_X, + LRANGE: LIST_X, + LREM: LIST_X, + LSET: LIST_X, + RPOP: LIST_X, + LTRIM: LIST_X, + RPUSH: LIST_X, + RPUSHX: LIST_X, } diff --git a/pkg/structure/generate/tem.yaml b/pkg/structure/generate/tem.yaml index 26d989f..d404084 100644 --- a/pkg/structure/generate/tem.yaml +++ b/pkg/structure/generate/tem.yaml @@ -11,4 +11,18 @@ STRING_X: - getrange - getset - strlen - - setnx \ No newline at end of file + - setnx + +LIST_X: + - lindex + - llen + - lpop + - lpush + - lpushx # 列表不存在则不插入 + - lrange + - lrem + - lset + - rpop + - ltrim # 对列表进行切片 + - rpush + - rpushx # 对已经存在的列表尾插 \ No newline at end of file diff --git a/protobuf/listx.proto b/protobuf/listx.proto new file mode 100644 index 0000000..b14c2e7 --- /dev/null +++ b/protobuf/listx.proto @@ -0,0 +1,87 @@ +syntax = "proto3"; +import "base.proto"; +option go_package = "pkg/proto"; + +message LindexRequest { + BaseKey key = 1; +} + +message LindexResponse { +} + +message LlenRequest { + BaseKey key = 1; +} + +message LlenResponse { +} + +message LpopRequest { + BaseKey key = 1; +} + +message LpopResponse { +} + +message LpushRequest { + BaseKey key = 1; +} + +message LpushResponse { +} + +message LpushxRequest { + BaseKey key = 1; +} + +message LpushxResponse { +} + +message LrangeRequest { + BaseKey key = 1; +} + +message LrangeResponse { +} + +message LremRequest { + BaseKey key = 1; +} + +message LremResponse { +} + +message LsetRequest { + BaseKey key = 1; +} + +message LsetResponse { +} + +message RpopRequest { + BaseKey key = 1; +} + +message RpopResponse { +} + +message LtrimRequest { + BaseKey key = 1; +} + +message LtrimResponse { +} + +message RpushRequest { + BaseKey key = 1; +} + +message RpushResponse { +} + +message RpushxRequest { + BaseKey key = 1; +} + +message RpushxResponse { +} diff --git a/protobuf/storage.proto b/protobuf/storage.proto index 5493bfa..6c0d976 100644 --- a/protobuf/storage.proto +++ b/protobuf/storage.proto @@ -6,6 +6,7 @@ syntax = "proto3"; option go_package = "pkg/proto"; import "stringx.proto"; +import "listx.proto"; service CommServer { @@ -19,4 +20,16 @@ service CommServer { rpc Getset (GetsetRequest) returns (GetsetResponse); rpc Strlen (StrlenRequest) returns (StrlenResponse); rpc Setnx (SetnxRequest) returns (SetnxResponse); + rpc Lindex (LindexRequest) returns (LindexResponse); + rpc Llen (LlenRequest) returns (LlenResponse); + rpc Lpop (LpopRequest) returns (LpopResponse); + rpc Lpush (LpushRequest) returns (LpushResponse); + rpc Lpushx (LpushxRequest) returns (LpushxResponse); + rpc Lrange (LrangeRequest) returns (LrangeResponse); + rpc Lrem (LremRequest) returns (LremResponse); + rpc Lset (LsetRequest) returns (LsetResponse); + rpc Rpop (RpopRequest) returns (RpopResponse); + rpc Ltrim (LtrimRequest) returns (LtrimResponse); + rpc Rpush (RpushRequest) returns (RpushResponse); + rpc Rpushx (RpushxRequest) returns (RpushxResponse); } \ No newline at end of file From 70a246f84c9e5501eab4e4453fd3e6706a5301c0 Mon Sep 17 00:00:00 2001 From: bandl <1658002533@qq.com> Date: Thu, 21 Oct 2021 16:18:30 +0800 Subject: [PATCH 02/18] feat(listx): add listx interface --- pkg/structure/interface.gen.go | 12 ++++++ pkg/structure/listx/listx.go | 68 ++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 pkg/structure/listx/listx.go diff --git a/pkg/structure/interface.gen.go b/pkg/structure/interface.gen.go index 29cfec8..112137a 100644 --- a/pkg/structure/interface.gen.go +++ b/pkg/structure/interface.gen.go @@ -24,3 +24,15 @@ type StringXInterface interface { Getrange(start, end int32) (string, error) GetLength() int } + +type ListXInterface interface { + KeyBaseInterface + LPush([]string) UpdateLength + RPush([]string) UpdateLength + LPop(int) ([]string, UpdateLength, error) + RPop(int) ([]string, UpdateLength, error) + Index(int) (string, error) + Insert(int, bool, []string) (UpdateLength, error) + Length() int + Slice(start, end int) (UpdateLength, error) // 切片, O(n)复杂度 +} diff --git a/pkg/structure/listx/listx.go b/pkg/structure/listx/listx.go new file mode 100644 index 0000000..56b8577 --- /dev/null +++ b/pkg/structure/listx/listx.go @@ -0,0 +1,68 @@ +package listx + +import "gitee.com/timedb/wheatCache/pkg/structure" + +/* +1. 双向链表 +2. 支持头尾操作 +3. 支持索引 +4. 支持切片 +*/ + +type Listx struct { +} + +func (l *Listx) SizeByte() int64 { + panic("not implemented") // TODO: Implement +} + +// RollBack TODO 事务相关, V2 实现 +func (l *Listx) RollBack() error { + panic("not implemented") // TODO: Implement +} + +// Begin 事务相关, V2 实现 +func (l *Listx) Begin() error { + panic("not implemented") // TODO: Implement +} + +// Comment 事务相关, V2 实现 +func (l *Listx) Comment() error { + panic("not implemented") // TODO: Implement +} + +func (l *Listx) Encode() ([]byte, error) { + panic("not implemented") // TODO: Implement +} + +func (l *Listx) LPush(_ []string) structure.UpdateLength { + panic("not implemented") // TODO: Implement +} + +func (l *Listx) RPush(_ []string) structure.UpdateLength { + panic("not implemented") // TODO: Implement +} + +func (l *Listx) LPop(_ int) ([]string, structure.UpdateLength, error) { + panic("not implemented") // TODO: Implement +} + +func (l *Listx) RPop(_ int) ([]string, structure.UpdateLength, error) { + panic("not implemented") // TODO: Implement +} + +func (l *Listx) Index(_ int) (string, error) { + panic("not implemented") // TODO: Implement +} + +func (l *Listx) Insert(_ int, _ bool, _ []string) (structure.UpdateLength, error) { + panic("not implemented") // TODO: Implement +} + +func (l *Listx) Length() int { + panic("not implemented") // TODO: Implement +} + +func (l *Listx) Slice(start int, end int) (structure.UpdateLength, error) { + panic("not implemented") // TODO: Implement +} From 41ef546d95eebb572e1ad00108ac343027012d18 Mon Sep 17 00:00:00 2001 From: bandl <1658002533@qq.com> Date: Fri, 22 Oct 2021 15:35:48 +0800 Subject: [PATCH 03/18] test(stringx): val test --- pkg/structure/stringx/string_test.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/structure/stringx/string_test.go b/pkg/structure/stringx/string_test.go index d9e53cb..1e77857 100644 --- a/pkg/structure/stringx/string_test.go +++ b/pkg/structure/stringx/string_test.go @@ -1,7 +1,9 @@ package stringx import ( + "fmt" "testing" + "unsafe" "gitee.com/timedb/wheatCache/pkg/structure" "github.com/stretchr/testify/require" @@ -89,3 +91,8 @@ func TestStringSingle_Getrange(t *testing.T) { require.NoError(t, err) require.Equal(t, "abc", k) } + +func TestPointSize(t *testing.T) { + var a *int32 + fmt.Println(unsafe.Sizeof(a)) +} From 15e1bb06afee4a3597c8978212cd4cc3a891c52c Mon Sep 17 00:00:00 2001 From: bandl <1658002533@qq.com> Date: Fri, 22 Oct 2021 15:36:25 +0800 Subject: [PATCH 04/18] feat(listx): add listx structure --- pkg/structure/interface.gen.go | 10 +- pkg/structure/listx/listx.go | 299 +++++++++++++++++++++++++++++++-- pkg/structure/value.go | 14 +- 3 files changed, 298 insertions(+), 25 deletions(-) diff --git a/pkg/structure/interface.gen.go b/pkg/structure/interface.gen.go index 112137a..f4a8d72 100644 --- a/pkg/structure/interface.gen.go +++ b/pkg/structure/interface.gen.go @@ -27,12 +27,12 @@ type StringXInterface interface { type ListXInterface interface { KeyBaseInterface - LPush([]string) UpdateLength - RPush([]string) UpdateLength - LPop(int) ([]string, UpdateLength, error) - RPop(int) ([]string, UpdateLength, error) + LPush(...string) UpdateLength + RPush(...string) UpdateLength + LPop(int) ([]string, UpdateLength) + RPop(int) ([]string, UpdateLength) Index(int) (string, error) - Insert(int, bool, []string) (UpdateLength, error) + Insert(int, bool, ...string) (UpdateLength, error) Length() int Slice(start, end int) (UpdateLength, error) // 切片, O(n)复杂度 } diff --git a/pkg/structure/listx/listx.go b/pkg/structure/listx/listx.go index 56b8577..9c45d18 100644 --- a/pkg/structure/listx/listx.go +++ b/pkg/structure/listx/listx.go @@ -1,6 +1,9 @@ package listx -import "gitee.com/timedb/wheatCache/pkg/structure" +import ( + "gitee.com/timedb/wheatCache/pkg/errorx" + "gitee.com/timedb/wheatCache/pkg/structure" +) /* 1. 双向链表 @@ -9,11 +12,103 @@ import "gitee.com/timedb/wheatCache/pkg/structure" 4. 支持切片 */ +type ListxNode struct { + next *ListxNode + pre *ListxNode + val *structure.Value +} + type Listx struct { + head *ListxNode + tail *ListxNode + length int +} + +func NewListXSingle() structure.ListXInterface { + return &Listx{ + head: nil, + tail: nil, + length: 0, + } +} + +func (l *Listx) initByValue(val string) int { + if l.head == nil && l.length == 0 { + node := &ListxNode{ + val: structure.NewValue(val), + } + l.head = node + l.tail = node + l.length = 1 + + return node.val.GetSize() + } + + return 0 +} + +// 定位到 list 的元素, 支持反向索引 +func (l *Listx) location(index int) (*ListxNode, error) { + // 正定位 + if index >= 0 { + node := l.head + for ; index != 0 && node != nil; index -= 1 { + node = node.next + } + + if node == nil { + return nil, errorx.New("index crosses the line") + } + return node, nil + } + + node := l.tail + for index = (-index) - 1; index != 0 && node != nil; { + node = node.pre + index -= 1 + } + + if node == nil { + return nil, errorx.New("index crosses the line") + } + return node, nil + +} + +// 转换为左索引,负数索引 +func (l *Listx) leftIndex(index int) (int, error) { + if index < 0 && l.length+index > 0 { + return index, nil + } + + if index >= 0 && index < l.length { + return index - l.length, nil + } + + return 0, errorx.New("the index is not valid, index:%d", index) +} + +// 转换为右索引,正数索引 +func (l *Listx) rightIndex(index int) (int, error) { + if index >= 0 && index < l.length { + return index, nil + } + + if index < 0 && l.length+index >= 0 { + return l.length + index, nil + } + + return 0, errorx.New("the index is not valid, index:%d", index) } func (l *Listx) SizeByte() int64 { - panic("not implemented") // TODO: Implement + bytes := 0 + r := l.head + for r != nil { + bytes += 16 + r.val.GetSize() + r = r.next + } + return int64(bytes) } // RollBack TODO 事务相关, V2 实现 @@ -35,34 +130,206 @@ func (l *Listx) Encode() ([]byte, error) { panic("not implemented") // TODO: Implement } -func (l *Listx) LPush(_ []string) structure.UpdateLength { - panic("not implemented") // TODO: Implement +func (l *Listx) LPush(valueStr ...string) structure.UpdateLength { + if len(valueStr) == 0 { + return 0 + } + + // 使用第一个元素尝试初始化列表 + updateLength := l.initByValue(valueStr[0]) + for i := 1; i < len(valueStr); i++ { + head := l.head + val := structure.NewValue(valueStr[i]) + node := &ListxNode{val: val} + node.next = head + head.pre = node + l.head = node + l.length += 1 + updateLength += val.GetSize() + } + return structure.UpdateLength(updateLength) } -func (l *Listx) RPush(_ []string) structure.UpdateLength { - panic("not implemented") // TODO: Implement +func (l *Listx) RPush(valueStr ...string) structure.UpdateLength { + if len(valueStr) == 0 { + return 0 + } + + updateLength := l.initByValue(valueStr[0]) + for i := 1; i < len(valueStr); i++ { + tail := l.tail + val := structure.NewValue(valueStr[i]) + node := &ListxNode{val: val} + tail.next = node + node.pre = tail + l.tail = node + l.length += 1 + updateLength += val.GetSize() + } + + return structure.UpdateLength(updateLength) } -func (l *Listx) LPop(_ int) ([]string, structure.UpdateLength, error) { - panic("not implemented") // TODO: Implement +func (l *Listx) LPop(count int) ([]string, structure.UpdateLength) { + values := make([]string, 0, count) + + head := l.head + + // 动态变化长度 + updateLength := 0 + + for nodePoint := 0; head != nil && nodePoint < count; nodePoint++ { + values = append(values, head.val.ToString()) + updateLength += head.val.GetSize() + head = head.next + l.length -= 1 + } + + if head != nil { + head.pre = nil + } else { + l.tail = nil + } + + l.head = head + + return values, structure.UpdateLength(updateLength) } -func (l *Listx) RPop(_ int) ([]string, structure.UpdateLength, error) { - panic("not implemented") // TODO: Implement +func (l *Listx) RPop(count int) ([]string, structure.UpdateLength) { + values := make([]string, 0, count) + tail := l.tail + + updateLength := 0 + + for nodePoint := 0; tail != nil && nodePoint < count; nodePoint++ { + values = append(values, tail.val.ToString()) + updateLength += tail.val.GetSize() + tail = tail.pre + l.length -= 1 + } + + if tail != nil { + tail.next = nil + } else { + l.head = nil + } + + l.tail = tail + + return values, structure.UpdateLength(updateLength) } -func (l *Listx) Index(_ int) (string, error) { - panic("not implemented") // TODO: Implement +func (l *Listx) Index(index int) (string, error) { + node, err := l.location(index) + if err != nil { + return "", nil + } + + return node.val.ToString(), nil } -func (l *Listx) Insert(_ int, _ bool, _ []string) (structure.UpdateLength, error) { - panic("not implemented") // TODO: Implement +// Insert, right 为 true 右添加,否则左添加 +func (l *Listx) Insert(index int, right bool, valueStr ...string) (structure.UpdateLength, error) { + targetNode, err := l.location(index) + if err != nil { + return 0, err + } + + updateLength := 0 + for _, valStr := range valueStr { + val := structure.NewValue(valStr) + node := &ListxNode{val: val} + + // 右插 + if right { + node.pre = targetNode + node.next = targetNode.next + + targetNode.next = node + targetNode.next.pre = node + + // 更新尾部 + if targetNode == l.tail { + l.tail = node + } + + targetNode = node + } else { + // 左插 + node.pre = targetNode.pre + targetNode.pre.next = node + + node.next = targetNode + targetNode.pre = node + + // 更新头部 + if targetNode == l.head { + l.head = node + } + targetNode = node + } + + updateLength += val.GetSize() + l.length += 1 + } + + return structure.UpdateLength(updateLength), nil } func (l *Listx) Length() int { - panic("not implemented") // TODO: Implement + return l.length } +// Slice 切片 func (l *Listx) Slice(start int, end int) (structure.UpdateLength, error) { - panic("not implemented") // TODO: Implement + + startOffset, err := l.rightIndex(start) + if err != nil { + return 0, err + } + + endRightOffset, err := l.rightIndex(end) + if err != nil && end != l.length { + return 0, errorx.New("index overstep the boundary, index: %d", end) + } + + if startOffset >= endRightOffset && endRightOffset != 0 { + return 0, errorx.New("the start index must be larger than the end index") + } + + // 计算左偏移 + var endOffset int + if end == l.length { + endOffset = 0 + } else { + endOffset, err = l.leftIndex(end) + if err != nil { + return 0, err + } + } + + updateLength := 0 + + // 右切片 + head := l.head + for nodePoint := 0; head != nil && nodePoint < startOffset; nodePoint++ { + updateLength += head.val.GetSize() + head = head.next + l.length -= 1 + } + l.head = head + head.pre = nil + + tail := l.tail + for nodePoint := 0; tail != nil && nodePoint < -endOffset; nodePoint++ { + updateLength += tail.val.GetSize() + tail = tail.pre + l.length -= 1 + } + + l.tail = tail + tail.next = nil + + return structure.UpdateLength(updateLength), nil } diff --git a/pkg/structure/value.go b/pkg/structure/value.go index be578ae..2b101b4 100644 --- a/pkg/structure/value.go +++ b/pkg/structure/value.go @@ -17,20 +17,26 @@ type Value struct { onType DynamicType } -func NewValue() *Value { - return &Value{ +func NewValue(val ...string) *Value { + + stcValue := &Value{ val: make([]byte, defaultLen), length: 0, onType: DynamicNull, } + + if len(val) > 0 { + stcValue.InferValue(val[0]) + } + return stcValue } func (v *Value) GetLength() int { - return len(v.val) + return v.length } func (v *Value) GetSize() int { - return v.length + return len(v.val) + 16 } func (v *Value) GetDynamicType() DynamicType { From a9dbb5169c5ca95a79febc7878ebc1750b3aeaa1 Mon Sep 17 00:00:00 2001 From: bandl <1658002533@qq.com> Date: Fri, 22 Oct 2021 15:37:25 +0800 Subject: [PATCH 05/18] test(listx): add listx test --- pkg/structure/listx/listx_test.go | 179 ++++++++++++++++++++++++++++++ 1 file changed, 179 insertions(+) create mode 100644 pkg/structure/listx/listx_test.go diff --git a/pkg/structure/listx/listx_test.go b/pkg/structure/listx/listx_test.go new file mode 100644 index 0000000..c0fd034 --- /dev/null +++ b/pkg/structure/listx/listx_test.go @@ -0,0 +1,179 @@ +package listx + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestListx_LPush_And_Pop(t *testing.T) { + list := NewListXSingle() + up := list.LPush("1", "2", "3") + require.Equal(t, list.Length(), 3) + + values, updateLength := list.LPop(3) + + require.Equal(t, values, []string{"3", "2", "1"}) + require.Equal(t, up, updateLength) + + list.LPush("1", "2", "3") + values, updateLength = list.LPop(1) + require.Equal(t, values, []string{"3"}) + require.Equal(t, int(updateLength), 24) + +} + +func TestListx_RPush_Pop(t *testing.T) { + list := NewListXSingle() + up := list.RPush("1", "2", "3") + require.Equal(t, list.Length(), 3) + + values, updateLength := list.LPop(3) + require.Equal(t, values, []string{"1", "2", "3"}) + require.Equal(t, up, updateLength) + + list.RPush("1", "2", "3") + values, updateLength = list.RPop(2) + require.Equal(t, values, []string{"3", "2"}) + require.Equal(t, int(updateLength), 48) +} + +func TestListx_location(t *testing.T) { + list := &Listx{ + head: nil, + tail: nil, + length: 0, + } + + list.RPush("1", "2", "3") + node, err := list.location(1) + require.NoError(t, err) + require.Equal(t, node.val.ToString(), "2") + + node, err = list.location(0) + require.NoError(t, err) + require.Equal(t, node.val.ToString(), "1") + + node, err = list.location(2) + require.NoError(t, err) + require.Equal(t, node.val.ToString(), "3") + + _, err = list.location(3) + require.Error(t, err) + + node, err = list.location(-1) + require.NoError(t, err) + require.Equal(t, node.val.ToString(), "3") + + node, err = list.location(-2) + require.NoError(t, err) + require.Equal(t, node.val.ToString(), "2") + + node, err = list.location(-3) + require.NoError(t, err) + require.Equal(t, node.val.ToString(), "1") + + _, err = list.location(-4) + require.Error(t, err) +} + +func TestListx_Insert(t *testing.T) { + list := NewListXSingle() + list.LPush("a", "b", "c", "d", "e") + val, _ := list.LPop(1) + require.Equal(t, val, []string{"e"}) + + res, err := list.Index(1) + require.NoError(t, err) + require.Equal(t, res, "c") + + _, err = list.Insert(1, false, "1", "2", "3") + require.NoError(t, err) + + // 全部取出 + val, _ = list.LPop(list.Length()) + require.Equal(t, val, []string{"d", "3", "2", "1", "c", "b", "a"}) + + list.RPush("1", "2", "3", "4", "5") + res, err = list.Index(-2) + require.NoError(t, err) + require.Equal(t, res, "4") + + _, err = list.Insert(-1, true, "6", "7") + require.NoError(t, err) + + val, _ = list.LPop(list.Length()) + require.Equal(t, val, []string{"1", "2", "3", "4", "5", "6", "7"}) +} + +func TestListx_Index(t *testing.T) { + list := &Listx{ + head: nil, + tail: nil, + length: 0, + } + + list.RPush("a", "b", "c", "d", "e") + + index := 2 + leftIndex, err := list.leftIndex(index) + require.NoError(t, err) + rightIndex, err := list.rightIndex(index) + require.NoError(t, err) + v1, err := list.Index(leftIndex) + require.NoError(t, err) + v2, err := list.Index(rightIndex) + require.NoError(t, err) + require.Equal(t, v1, v2) +} + +func TestListx_Slice(t *testing.T) { + list := NewListXSingle() + list.RPush("a", "b", "c", "d", "e") + + // 主流程测试 + list.Slice(1, 2) + values, _ := list.LPop(list.Length()) + require.Equal(t, values, []string{"b"}) + + list2 := NewListXSingle() + list2.RPush("1", "2", "3", "4", "5") + + list2.Slice(0, 4) + values, _ = list2.LPop(list2.Length()) + require.Equal(t, values, []string{"1", "2", "3", "4"}) + + list3 := NewListXSingle() + list3.RPush("1", "2", "3", "4", "5") + + list3.Slice(2, list3.Length()) + values, _ = list3.LPop(list3.Length()) + require.Equal(t, values, []string{"3", "4", "5"}) + + // 测试负数索引 + list3 = NewListXSingle() + list3.RPush("1", "2", "3", "4", "5") + + _, err := list3.Slice(0, -2) + require.NoError(t, err) + values, _ = list3.LPop(list3.Length()) + require.Equal(t, values, []string{"1", "2", "3"}) + + // 测试负数双边际 + list3 = NewListXSingle() + list3.RPush("1", "2", "3", "4", "5") + + _, err = list3.Slice(-3, -2) + require.NoError(t, err) + values, _ = list3.LPop(list3.Length()) + require.Equal(t, values, []string{"3"}) + + // 测试负数边际 + list3 = NewListXSingle() + list3.RPush("1", "2", "3", "4", "5") + + _, err = list3.Slice(-5, 4) + require.NoError(t, err) + values, _ = list3.LPop(list3.Length()) + require.Equal(t, values, []string{"1", "2", "3", "4"}) +} From d42b01ff775a67077a214bec0b4c09d0290448c4 Mon Sep 17 00:00:00 2001 From: bandl <1658002533@qq.com> Date: Fri, 22 Oct 2021 15:56:44 +0800 Subject: [PATCH 06/18] feat(structure): update interface view --- pkg/structure/define.go | 37 +++++++++++++++++++++++++++++++++ pkg/structure/interface.gen.go | 38 ---------------------------------- 2 files changed, 37 insertions(+), 38 deletions(-) delete mode 100644 pkg/structure/interface.gen.go diff --git a/pkg/structure/define.go b/pkg/structure/define.go index 2563d9c..cdd97ba 100644 --- a/pkg/structure/define.go +++ b/pkg/structure/define.go @@ -14,3 +14,40 @@ const ( DynamicFloat DynamicString ) + +type KeyBaseInterface interface { + SizeByte() int64 + + // RollBack TODO 事务相关, V2 实现 + RollBack() error + // Begin 事务相关, V2 实现 + Begin() error + // Comment 事务相关, V2 实现 + Comment() error + + Encode() ([]byte, error) +} + +type StringXInterface interface { + KeyBaseInterface + Set(string) (string, UpdateLength) + Get() string + Add(int32) (string, error) + Reduce(int32) (string, error) + Setbit(int32, bool) UpdateLength + Getbit(int32) (bool, error) + Getrange(start, end int32) (string, error) + GetLength() int +} + +type ListXInterface interface { + KeyBaseInterface + LPush(...string) UpdateLength + RPush(...string) UpdateLength + LPop(int) ([]string, UpdateLength) + RPop(int) ([]string, UpdateLength) + Index(int) (string, error) + Insert(int, bool, ...string) (UpdateLength, error) + Length() int + Slice(start, end int) (UpdateLength, error) // 切片, O(n)复杂度 +} diff --git a/pkg/structure/interface.gen.go b/pkg/structure/interface.gen.go deleted file mode 100644 index f4a8d72..0000000 --- a/pkg/structure/interface.gen.go +++ /dev/null @@ -1,38 +0,0 @@ -package structure - -type KeyBaseInterface interface { - SizeByte() int64 - - // RollBack TODO 事务相关, V2 实现 - RollBack() error - // Begin 事务相关, V2 实现 - Begin() error - // Comment 事务相关, V2 实现 - Comment() error - - Encode() ([]byte, error) -} - -type StringXInterface interface { - KeyBaseInterface - Set(string) (string, UpdateLength) - Get() string - Add(int32) (string, error) - Reduce(int32) (string, error) - Setbit(int32, bool) UpdateLength - Getbit(int32) (bool, error) - Getrange(start, end int32) (string, error) - GetLength() int -} - -type ListXInterface interface { - KeyBaseInterface - LPush(...string) UpdateLength - RPush(...string) UpdateLength - LPop(int) ([]string, UpdateLength) - RPop(int) ([]string, UpdateLength) - Index(int) (string, error) - Insert(int, bool, ...string) (UpdateLength, error) - Length() int - Slice(start, end int) (UpdateLength, error) // 切片, O(n)复杂度 -} From f022ae9cbe77e389e4f84eb826d4056154cba1d9 Mon Sep 17 00:00:00 2001 From: bandl <1658002533@qq.com> Date: Fri, 22 Oct 2021 16:11:59 +0800 Subject: [PATCH 07/18] doc(structure): add doc --- doc/pkg/structure/结构体开发文档.md | 60 ++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 doc/pkg/structure/结构体开发文档.md diff --git a/doc/pkg/structure/结构体开发文档.md b/doc/pkg/structure/结构体开发文档.md new file mode 100644 index 0000000..3accd7b --- /dev/null +++ b/doc/pkg/structure/结构体开发文档.md @@ -0,0 +1,60 @@ +### 结构体开发文档 + +#### 基础结构体开发 + +- 基础结构体放到 /pkg/structure。 + +- 每个结构 类型都以 x 结尾,如 listx, stringx。 + +- 在 pkg/structure/define.go 文件中添加对应结构体的接口,主要为 了保证项目可以扩展线程安全结构体, 以及结构体接口的实现, 目前 lru 采用 single 模式, 可以只开发 single 的结构体,如 stringxSingle。 + +- 请在结构体包中 补充单元测试。 + +#### 目前实现结构体接口说明 + +> ps: 所有的详细用法都可以查看单元测试文件。 + +```go +// stringx +type StringXInterface interface { + KeyBaseInterface + // 重新设置一个 值 + Set(string) (string, UpdateLength) + // 获取值的 string 形式 + Get() string + // 值自动增加 一个值,只对 float 和 string 有效 + Add(int32) (string, error) + // 值自动增加 减少值,只对 float 和 string 有效 + Reduce(int32) (string, error) + // 使用位图类型 + Setbit(int32, bool) UpdateLength + Getbit(int32) (bool, error) + // 获取字符串的切片 + Getrange(start, end int32) (string, error) + GetLength() int +} + +// listx +type ListXInterface interface { + KeyBaseInterface + LPush(...string) UpdateLength + RPush(...string) UpdateLength + LPop(int) ([]string, UpdateLength) + RPop(int) ([]string, UpdateLength) + Index(int) (string, error) + // 插入一组数据, bool 类型表示是否右插(尾插),false 时采用左插(头插) + Insert(int, bool, ...string) (UpdateLength, error) + Length() int + // 切片, O(n)复杂度 + Slice(start, end int) (UpdateLength, error) +} +``` + + +### structure.Value 类型 +- 结构体的数据区域全部使用 structure.Value 类型存储。 +- structure.Value 主要实现了 sting, int64, float64 的存储接口。 +- structure.Value 非常容易计算内存占用。 +- structure.UpdateLength 指的是在进行某一个操作以后,内存大小的变化。 +- 为了保证 lru 的存储效率,lru 不会去遍历全部的 key 来重新计算大小,而是根据 UpdateLength 来动态更新 lru 的大小,具体实现在 dao 中。 +- structure.Value 类型的使用方法可以在 pkg/structure/value_test.go 中获取。 \ No newline at end of file From e6eb86de0506d10dde5821ded9f3eda31898d97b Mon Sep 17 00:00:00 2001 From: bandl <1658002533@qq.com> Date: Fri, 22 Oct 2021 16:12:13 +0800 Subject: [PATCH 08/18] doc(middle): update doc --- doc/pkg/middle/middle.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/pkg/middle/middle.md b/doc/pkg/middle/middle.md index 51eec50..6988095 100644 --- a/doc/pkg/middle/middle.md +++ b/doc/pkg/middle/middle.md @@ -29,7 +29,7 @@ type MiddleToolsInterface interface { } ### 插件的New方法规定为 NewMiddleWare() - 每个插件都要定义NewMiddleWare() + 每个插件都要定义 NewMiddleWare() From 77988052eeacb50f04148b0d4971d4b148d45293 Mon Sep 17 00:00:00 2001 From: bandl <1658002533@qq.com> Date: Fri, 22 Oct 2021 16:26:17 +0800 Subject: [PATCH 09/18] doc(make): add make doc --- doc/make.md | 32 ++++++++++++++++++++++++++++++++ doc/make/make.md | 17 ----------------- 2 files changed, 32 insertions(+), 17 deletions(-) create mode 100644 doc/make.md delete mode 100644 doc/make/make.md diff --git a/doc/make.md b/doc/make.md new file mode 100644 index 0000000..57e4227 --- /dev/null +++ b/doc/make.md @@ -0,0 +1,32 @@ +### 构建工具文档 + +#### dcgen +1. 根据结构体接口模板生成 proto 文件 +2. 迁移 proto 到 pkg/proto 下 +3. 更新结构体常量 + +>PS : 开发一个 storage 的新接口时一般有以下步骤 +>1. 修改 storage 接口配置文件 +>2. make dcgen +>3. 修改生成的 proto 文件 +>4. make dcgen +>5. 添加 storage 的操作接口 + + +#### build-storage +编译并且生成 /bin/storage + +#### build-gateway +编译并且生成 /bin/gateway + +#### install +1. 安装项目,需要 sudo + +#### storage +根据配置文件启动 storage + +#### gateway +根据配置文件启动 gateway + +#### init-conf +根据配置文件文档初始化配置文件到 /etc/wheat-cache/wheat-cache.yaml diff --git a/doc/make/make.md b/doc/make/make.md deleted file mode 100644 index b0afd4e..0000000 --- a/doc/make/make.md +++ /dev/null @@ -1,17 +0,0 @@ -## 构建工具文档 - -### 构建 proto (grpc-go) -```shell -make dcgen -``` - -### 编译全部的 go 项目 -```shell -make build -``` - -### 启动 storage 服务 -```shell -make dev -``` -### 根据配置生成 结构体命令 From 8c5c594ac5339434e9784461ac97f90ee392d28a Mon Sep 17 00:00:00 2001 From: bandl <1658002533@qq.com> Date: Fri, 22 Oct 2021 18:15:26 +0800 Subject: [PATCH 10/18] feat(proto): update proto --- pkg/proto/listx.pb.go | 302 ++++++++++++++++++++++++++++++++++-------- protobuf/listx.proto | 21 +++ 2 files changed, 269 insertions(+), 54 deletions(-) diff --git a/pkg/proto/listx.pb.go b/pkg/proto/listx.pb.go index 160ceee..d35d853 100644 --- a/pkg/proto/listx.pb.go +++ b/pkg/proto/listx.pb.go @@ -25,7 +25,8 @@ type LindexRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Key *BaseKey `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Key *BaseKey `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Index int32 `protobuf:"varint,2,opt,name=index,proto3" json:"index,omitempty"` } func (x *LindexRequest) Reset() { @@ -67,10 +68,19 @@ func (x *LindexRequest) GetKey() *BaseKey { return nil } +func (x *LindexRequest) GetIndex() int32 { + if x != nil { + return x.Index + } + return 0 +} + type LindexResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + + Result string `protobuf:"bytes,1,opt,name=result,proto3" json:"result,omitempty"` } func (x *LindexResponse) Reset() { @@ -105,6 +115,13 @@ func (*LindexResponse) Descriptor() ([]byte, []int) { return file_listx_proto_rawDescGZIP(), []int{1} } +func (x *LindexResponse) GetResult() string { + if x != nil { + return x.Result + } + return "" +} + type LlenRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -156,6 +173,8 @@ type LlenResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + + Length int32 `protobuf:"varint,1,opt,name=length,proto3" json:"length,omitempty"` } func (x *LlenResponse) Reset() { @@ -190,12 +209,20 @@ func (*LlenResponse) Descriptor() ([]byte, []int) { return file_listx_proto_rawDescGZIP(), []int{3} } +func (x *LlenResponse) GetLength() int32 { + if x != nil { + return x.Length + } + return 0 +} + type LpopRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Key *BaseKey `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Key *BaseKey `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Count int32 `protobuf:"varint,2,opt,name=count,proto3" json:"count,omitempty"` } func (x *LpopRequest) Reset() { @@ -237,10 +264,19 @@ func (x *LpopRequest) GetKey() *BaseKey { return nil } +func (x *LpopRequest) GetCount() int32 { + if x != nil { + return x.Count + } + return 0 +} + type LpopResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + + Results []string `protobuf:"bytes,1,rep,name=results,proto3" json:"results,omitempty"` } func (x *LpopResponse) Reset() { @@ -275,12 +311,20 @@ func (*LpopResponse) Descriptor() ([]byte, []int) { return file_listx_proto_rawDescGZIP(), []int{5} } +func (x *LpopResponse) GetResults() []string { + if x != nil { + return x.Results + } + return nil +} + type LpushRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Key *BaseKey `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Key *BaseKey `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Values []string `protobuf:"bytes,2,rep,name=values,proto3" json:"values,omitempty"` } func (x *LpushRequest) Reset() { @@ -322,6 +366,13 @@ func (x *LpushRequest) GetKey() *BaseKey { return nil } +func (x *LpushRequest) GetValues() []string { + if x != nil { + return x.Values + } + return nil +} + type LpushResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -365,7 +416,8 @@ type LpushxRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Key *BaseKey `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Key *BaseKey `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Values []string `protobuf:"bytes,2,rep,name=values,proto3" json:"values,omitempty"` } func (x *LpushxRequest) Reset() { @@ -407,6 +459,13 @@ func (x *LpushxRequest) GetKey() *BaseKey { return nil } +func (x *LpushxRequest) GetValues() []string { + if x != nil { + return x.Values + } + return nil +} + type LpushxResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -450,7 +509,9 @@ type LrangeRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Key *BaseKey `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Key *BaseKey `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Start int32 `protobuf:"varint,2,opt,name=start,proto3" json:"start,omitempty"` + End int32 `protobuf:"varint,3,opt,name=end,proto3" json:"end,omitempty"` } func (x *LrangeRequest) Reset() { @@ -492,10 +553,26 @@ func (x *LrangeRequest) GetKey() *BaseKey { return nil } +func (x *LrangeRequest) GetStart() int32 { + if x != nil { + return x.Start + } + return 0 +} + +func (x *LrangeRequest) GetEnd() int32 { + if x != nil { + return x.End + } + return 0 +} + type LrangeResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + + Values []string `protobuf:"bytes,2,rep,name=values,proto3" json:"values,omitempty"` } func (x *LrangeResponse) Reset() { @@ -530,12 +607,22 @@ func (*LrangeResponse) Descriptor() ([]byte, []int) { return file_listx_proto_rawDescGZIP(), []int{11} } +func (x *LrangeResponse) GetValues() []string { + if x != nil { + return x.Values + } + return nil +} + type LremRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Key *BaseKey `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + // count > 0 头搜索,count < 0 尾搜索 + Count int32 `protobuf:"varint,2,opt,name=count,proto3" json:"count,omitempty"` + Value string `protobuf:"bytes,3,opt,name=value,proto3" json:"value,omitempty"` } func (x *LremRequest) Reset() { @@ -577,10 +664,26 @@ func (x *LremRequest) GetKey() *BaseKey { return nil } +func (x *LremRequest) GetCount() int32 { + if x != nil { + return x.Count + } + return 0 +} + +func (x *LremRequest) GetValue() string { + if x != nil { + return x.Value + } + return "" +} + type LremResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + + Count int32 `protobuf:"varint,1,opt,name=count,proto3" json:"count,omitempty"` } func (x *LremResponse) Reset() { @@ -615,12 +718,21 @@ func (*LremResponse) Descriptor() ([]byte, []int) { return file_listx_proto_rawDescGZIP(), []int{13} } +func (x *LremResponse) GetCount() int32 { + if x != nil { + return x.Count + } + return 0 +} + type LsetRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Key *BaseKey `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Key *BaseKey `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Index int32 `protobuf:"varint,2,opt,name=index,proto3" json:"index,omitempty"` + Value string `protobuf:"bytes,3,opt,name=value,proto3" json:"value,omitempty"` } func (x *LsetRequest) Reset() { @@ -662,6 +774,20 @@ func (x *LsetRequest) GetKey() *BaseKey { return nil } +func (x *LsetRequest) GetIndex() int32 { + if x != nil { + return x.Index + } + return 0 +} + +func (x *LsetRequest) GetValue() string { + if x != nil { + return x.Value + } + return "" +} + type LsetResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -705,7 +831,8 @@ type RpopRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Key *BaseKey `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Key *BaseKey `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Count int32 `protobuf:"varint,2,opt,name=count,proto3" json:"count,omitempty"` } func (x *RpopRequest) Reset() { @@ -747,6 +874,13 @@ func (x *RpopRequest) GetKey() *BaseKey { return nil } +func (x *RpopRequest) GetCount() int32 { + if x != nil { + return x.Count + } + return 0 +} + type RpopResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -790,7 +924,9 @@ type LtrimRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Key *BaseKey `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Key *BaseKey `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Start int32 `protobuf:"varint,2,opt,name=start,proto3" json:"start,omitempty"` + End int32 `protobuf:"varint,3,opt,name=end,proto3" json:"end,omitempty"` } func (x *LtrimRequest) Reset() { @@ -832,6 +968,20 @@ func (x *LtrimRequest) GetKey() *BaseKey { return nil } +func (x *LtrimRequest) GetStart() int32 { + if x != nil { + return x.Start + } + return 0 +} + +func (x *LtrimRequest) GetEnd() int32 { + if x != nil { + return x.End + } + return 0 +} + type LtrimResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -875,7 +1025,8 @@ type RpushRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Key *BaseKey `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Key *BaseKey `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Values []string `protobuf:"bytes,2,rep,name=values,proto3" json:"values,omitempty"` } func (x *RpushRequest) Reset() { @@ -917,6 +1068,13 @@ func (x *RpushRequest) GetKey() *BaseKey { return nil } +func (x *RpushRequest) GetValues() []string { + if x != nil { + return x.Values + } + return nil +} + type RpushResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -960,7 +1118,8 @@ type RpushxRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Key *BaseKey `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Key *BaseKey `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Values []string `protobuf:"bytes,2,rep,name=values,proto3" json:"values,omitempty"` } func (x *RpushxRequest) Reset() { @@ -1002,6 +1161,13 @@ func (x *RpushxRequest) GetKey() *BaseKey { return nil } +func (x *RpushxRequest) GetValues() []string { + if x != nil { + return x.Values + } + return nil +} + type RpushxResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -1044,54 +1210,82 @@ var File_listx_proto protoreflect.FileDescriptor var file_listx_proto_rawDesc = []byte{ 0x0a, 0x0b, 0x6c, 0x69, 0x73, 0x74, 0x78, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0a, 0x62, - 0x61, 0x73, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x2b, 0x0a, 0x0d, 0x4c, 0x69, 0x6e, + 0x61, 0x73, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x41, 0x0a, 0x0d, 0x4c, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x4b, 0x65, - 0x79, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x22, 0x10, 0x0a, 0x0e, 0x4c, 0x69, 0x6e, 0x64, 0x65, 0x78, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x29, 0x0a, 0x0b, 0x4c, 0x6c, 0x65, 0x6e, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x4b, 0x65, 0x79, 0x52, 0x03, - 0x6b, 0x65, 0x79, 0x22, 0x0e, 0x0a, 0x0c, 0x4c, 0x6c, 0x65, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x29, 0x0a, 0x0b, 0x4c, 0x70, 0x6f, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x08, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x4b, 0x65, 0x79, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x22, 0x0e, - 0x0a, 0x0c, 0x4c, 0x70, 0x6f, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x2a, - 0x0a, 0x0c, 0x4c, 0x70, 0x75, 0x73, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, - 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x42, 0x61, - 0x73, 0x65, 0x4b, 0x65, 0x79, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x22, 0x0f, 0x0a, 0x0d, 0x4c, 0x70, - 0x75, 0x73, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x2b, 0x0a, 0x0d, 0x4c, - 0x70, 0x75, 0x73, 0x68, 0x78, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x03, - 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x42, 0x61, 0x73, 0x65, - 0x4b, 0x65, 0x79, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x22, 0x10, 0x0a, 0x0e, 0x4c, 0x70, 0x75, 0x73, - 0x68, 0x78, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x2b, 0x0a, 0x0d, 0x4c, 0x72, - 0x61, 0x6e, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x03, 0x6b, - 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x4b, - 0x65, 0x79, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x22, 0x10, 0x0a, 0x0e, 0x4c, 0x72, 0x61, 0x6e, 0x67, - 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x29, 0x0a, 0x0b, 0x4c, 0x72, 0x65, - 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x4b, 0x65, 0x79, 0x52, - 0x03, 0x6b, 0x65, 0x79, 0x22, 0x0e, 0x0a, 0x0c, 0x4c, 0x72, 0x65, 0x6d, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x29, 0x0a, 0x0b, 0x4c, 0x73, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x08, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x4b, 0x65, 0x79, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x22, - 0x0e, 0x0a, 0x0c, 0x4c, 0x73, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x29, 0x0a, 0x0b, 0x52, 0x70, 0x6f, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, - 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x42, 0x61, - 0x73, 0x65, 0x4b, 0x65, 0x79, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x22, 0x0e, 0x0a, 0x0c, 0x52, 0x70, - 0x6f, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x2a, 0x0a, 0x0c, 0x4c, 0x74, - 0x72, 0x69, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x03, 0x6b, 0x65, - 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x4b, 0x65, - 0x79, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x22, 0x0f, 0x0a, 0x0d, 0x4c, 0x74, 0x72, 0x69, 0x6d, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x2a, 0x0a, 0x0c, 0x52, 0x70, 0x75, 0x73, 0x68, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x4b, 0x65, 0x79, 0x52, 0x03, - 0x6b, 0x65, 0x79, 0x22, 0x0f, 0x0a, 0x0d, 0x52, 0x70, 0x75, 0x73, 0x68, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x2b, 0x0a, 0x0d, 0x52, 0x70, 0x75, 0x73, 0x68, 0x78, 0x52, 0x65, + 0x79, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x22, 0x28, 0x0a, 0x0e, + 0x4c, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, + 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, + 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x29, 0x0a, 0x0b, 0x4c, 0x6c, 0x65, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x4b, 0x65, 0x79, 0x52, 0x03, 0x6b, 0x65, - 0x79, 0x22, 0x10, 0x0a, 0x0e, 0x52, 0x70, 0x75, 0x73, 0x68, 0x78, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x42, 0x0b, 0x5a, 0x09, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x79, 0x22, 0x26, 0x0a, 0x0c, 0x4c, 0x6c, 0x65, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x16, 0x0a, 0x06, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x06, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x22, 0x3f, 0x0a, 0x0b, 0x4c, 0x70, 0x6f, + 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x4b, 0x65, 0x79, 0x52, + 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x28, 0x0a, 0x0c, 0x4c, 0x70, + 0x6f, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x65, + 0x73, 0x75, 0x6c, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x72, 0x65, 0x73, + 0x75, 0x6c, 0x74, 0x73, 0x22, 0x42, 0x0a, 0x0c, 0x4c, 0x70, 0x75, 0x73, 0x68, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x08, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x4b, 0x65, 0x79, 0x52, 0x03, 0x6b, 0x65, 0x79, + 0x12, 0x16, 0x0a, 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, + 0x52, 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x22, 0x0f, 0x0a, 0x0d, 0x4c, 0x70, 0x75, 0x73, + 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x43, 0x0a, 0x0d, 0x4c, 0x70, 0x75, + 0x73, 0x68, 0x78, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x03, 0x6b, 0x65, + 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x4b, 0x65, + 0x79, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, + 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x22, 0x10, + 0x0a, 0x0e, 0x4c, 0x70, 0x75, 0x73, 0x68, 0x78, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x22, 0x53, 0x0a, 0x0d, 0x4c, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x12, 0x1a, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, + 0x2e, 0x42, 0x61, 0x73, 0x65, 0x4b, 0x65, 0x79, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, + 0x05, 0x73, 0x74, 0x61, 0x72, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x73, 0x74, + 0x61, 0x72, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x65, 0x6e, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, + 0x52, 0x03, 0x65, 0x6e, 0x64, 0x22, 0x28, 0x0a, 0x0e, 0x4c, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x22, + 0x55, 0x0a, 0x0b, 0x4c, 0x72, 0x65, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, + 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x42, 0x61, + 0x73, 0x65, 0x4b, 0x65, 0x79, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, + 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, + 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x24, 0x0a, 0x0c, 0x4c, 0x72, 0x65, 0x6d, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x55, 0x0a, 0x0b, + 0x4c, 0x73, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x03, 0x6b, + 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x4b, + 0x65, 0x79, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x14, 0x0a, + 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, + 0x6c, 0x75, 0x65, 0x22, 0x0e, 0x0a, 0x0c, 0x4c, 0x73, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x3f, 0x0a, 0x0b, 0x52, 0x70, 0x6f, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x08, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x4b, 0x65, 0x79, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, + 0x0a, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x63, + 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x0e, 0x0a, 0x0c, 0x52, 0x70, 0x6f, 0x70, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x52, 0x0a, 0x0c, 0x4c, 0x74, 0x72, 0x69, 0x6d, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x08, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x4b, 0x65, 0x79, 0x52, 0x03, 0x6b, 0x65, 0x79, + 0x12, 0x14, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x72, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x05, 0x73, 0x74, 0x61, 0x72, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x65, 0x6e, 0x64, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x03, 0x65, 0x6e, 0x64, 0x22, 0x0f, 0x0a, 0x0d, 0x4c, 0x74, 0x72, 0x69, + 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x42, 0x0a, 0x0c, 0x52, 0x70, 0x75, + 0x73, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x03, 0x6b, 0x65, 0x79, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x4b, 0x65, 0x79, + 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, + 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x22, 0x0f, 0x0a, + 0x0d, 0x52, 0x70, 0x75, 0x73, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x43, + 0x0a, 0x0d, 0x52, 0x70, 0x75, 0x73, 0x68, 0x78, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, + 0x1a, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x42, + 0x61, 0x73, 0x65, 0x4b, 0x65, 0x79, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x76, 0x61, 0x6c, + 0x75, 0x65, 0x73, 0x22, 0x10, 0x0a, 0x0e, 0x52, 0x70, 0x75, 0x73, 0x68, 0x78, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x0b, 0x5a, 0x09, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/protobuf/listx.proto b/protobuf/listx.proto index b14c2e7..2a2e01a 100644 --- a/protobuf/listx.proto +++ b/protobuf/listx.proto @@ -4,9 +4,11 @@ option go_package = "pkg/proto"; message LindexRequest { BaseKey key = 1; + int32 index = 2; } message LindexResponse { + string result = 1; } message LlenRequest { @@ -14,17 +16,21 @@ message LlenRequest { } message LlenResponse { + int32 length = 1; } message LpopRequest { BaseKey key = 1; + int32 count = 2; } message LpopResponse { + repeated string results = 1; } message LpushRequest { BaseKey key = 1; + repeated string values = 2; } message LpushResponse { @@ -32,6 +38,7 @@ message LpushResponse { message LpushxRequest { BaseKey key = 1; + repeated string values = 2; } message LpushxResponse { @@ -39,20 +46,29 @@ message LpushxResponse { message LrangeRequest { BaseKey key = 1; + int32 start = 2; + int32 end = 3; } message LrangeResponse { + repeated string values = 2; } message LremRequest { BaseKey key = 1; + // count > 0 头搜索,count < 0 尾搜索 + int32 count = 2; + string value = 3; } message LremResponse { + int32 count = 1; } message LsetRequest { BaseKey key = 1; + int32 index = 2; + string value = 3; } message LsetResponse { @@ -60,6 +76,7 @@ message LsetResponse { message RpopRequest { BaseKey key = 1; + int32 count = 2; } message RpopResponse { @@ -67,6 +84,8 @@ message RpopResponse { message LtrimRequest { BaseKey key = 1; + int32 start = 2; + int32 end = 3; } message LtrimResponse { @@ -74,6 +93,7 @@ message LtrimResponse { message RpushRequest { BaseKey key = 1; + repeated string values = 2; } message RpushResponse { @@ -81,6 +101,7 @@ message RpushResponse { message RpushxRequest { BaseKey key = 1; + repeated string values = 2; } message RpushxResponse { From 8883abd461baf1a7c49560ea08c3e798df315b41 Mon Sep 17 00:00:00 2001 From: bandl <1658002533@qq.com> Date: Fri, 22 Oct 2021 22:01:48 +0800 Subject: [PATCH 11/18] feat(listx): add range func --- pkg/structure/listx/listx.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/pkg/structure/listx/listx.go b/pkg/structure/listx/listx.go index 9c45d18..c804c91 100644 --- a/pkg/structure/listx/listx.go +++ b/pkg/structure/listx/listx.go @@ -333,3 +333,31 @@ func (l *Listx) Slice(start int, end int) (structure.UpdateLength, error) { return structure.UpdateLength(updateLength), nil } + +func (l *Listx) Range(start, end int) ([]string, error) { + startOffset, err := l.rightIndex(start) + if err != nil { + return nil, err + } + + endRightOffset, err := l.rightIndex(end) + if err != nil && end != l.length { + return nil, errorx.New("index overstep the boundary, index: %d", end) + } + + if startOffset >= endRightOffset && endRightOffset != 0 { + return nil, errorx.New("the start index must be larger than the end index") + } + + head := l.head + for nodePoint := 0; head != nil && nodePoint < startOffset; nodePoint++ { + head = head.next + } + + values := make([]string, 0) + for i := 0; i < endRightOffset-startOffset && head != nil; i++ { + values = append(values, head.val.ToString()) + head = head.next + } + return values, nil +} From 74e42e78ac2dd0d724a55fcb2d5079822a173f73 Mon Sep 17 00:00:00 2001 From: bandl <1658002533@qq.com> Date: Fri, 22 Oct 2021 22:01:58 +0800 Subject: [PATCH 12/18] test(listx): test range --- pkg/structure/listx/listx_test.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/pkg/structure/listx/listx_test.go b/pkg/structure/listx/listx_test.go index c0fd034..bc34617 100644 --- a/pkg/structure/listx/listx_test.go +++ b/pkg/structure/listx/listx_test.go @@ -177,3 +177,30 @@ func TestListx_Slice(t *testing.T) { values, _ = list3.LPop(list3.Length()) require.Equal(t, values, []string{"1", "2", "3", "4"}) } + +func TestListx_Range(t *testing.T) { + list := NewListXSingle() + list.RPush("a", "b", "c", "d", "e") + val, err := list.Range(0, 2) + require.NoError(t, err) + + require.Equal(t, val, []string{"a", "b"}) + + val, err = list.Range(0, -1) + require.NoError(t, err) + + require.Equal(t, val, []string{"a", "b", "c", "d"}) + + val, err = list.Range(-3, 3) + require.NoError(t, err) + + require.Equal(t, val, []string{"c"}) + + val, err = list.Range(-1, list.Length()) + require.NoError(t, err) + + require.Equal(t, val, []string{}) + + _, err = list.Range(6, -1) + require.Error(t, err) +} From 4f6fb64ecc57315bbbaa16cba50fdc2399943fb7 Mon Sep 17 00:00:00 2001 From: bandl <1658002533@qq.com> Date: Sat, 23 Oct 2021 15:17:57 +0800 Subject: [PATCH 13/18] feat(listx): add listx --- pkg/structure/define.go | 2 ++ pkg/structure/listx/listx.go | 65 ++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/pkg/structure/define.go b/pkg/structure/define.go index cdd97ba..22ec2d1 100644 --- a/pkg/structure/define.go +++ b/pkg/structure/define.go @@ -50,4 +50,6 @@ type ListXInterface interface { Insert(int, bool, ...string) (UpdateLength, error) Length() int Slice(start, end int) (UpdateLength, error) // 切片, O(n)复杂度 + Range(start, end int) ([]string, error) + Remove(value string, count int) (int, UpdateLength) } diff --git a/pkg/structure/listx/listx.go b/pkg/structure/listx/listx.go index c804c91..552de2b 100644 --- a/pkg/structure/listx/listx.go +++ b/pkg/structure/listx/listx.go @@ -101,6 +101,31 @@ func (l *Listx) rightIndex(index int) (int, error) { return 0, errorx.New("the index is not valid, index:%d", index) } +func (l *Listx) remove(node *ListxNode) { + + if node == nil { + return + } + + l.length -= 1 + + if node == l.head { + l.head = node.next + node.next.pre = nil + return + } + + if node == l.tail { + l.tail = node.pre + node.pre.next = nil + return + } + + node.pre.next = node.next + node.next.pre = node.pre + +} + func (l *Listx) SizeByte() int64 { bytes := 0 r := l.head @@ -334,6 +359,7 @@ func (l *Listx) Slice(start int, end int) (structure.UpdateLength, error) { return structure.UpdateLength(updateLength), nil } +// Range 遍历 func (l *Listx) Range(start, end int) ([]string, error) { startOffset, err := l.rightIndex(start) if err != nil { @@ -361,3 +387,42 @@ func (l *Listx) Range(start, end int) ([]string, error) { } return values, nil } + +func (l *Listx) Remove(value string, count int) (int, structure.UpdateLength) { + + if count == 0 { + return 0, 0 + } + + updateLength := 0 + remCount := count + + // 头删除 + if count > 0 { + node := l.head + for node != nil && remCount > 0 { + if node.val.ToString() == value { + l.remove(node) + remCount-- + updateLength += node.val.GetSize() + } + node = node.next + } + + return count - remCount, structure.UpdateLength(updateLength) + } + + // 尾删除 + node := l.tail + for node != nil && remCount < 0 { + if node.val.ToString() == value { + l.remove(node) + remCount++ + updateLength += node.val.GetSize() + } + node = node.pre + } + + return remCount - count, structure.UpdateLength(updateLength) + +} From 7ce1a55d0e2ab0ed355bbe57c4dc20a97ac8b10a Mon Sep 17 00:00:00 2001 From: bandl <1658002533@qq.com> Date: Sat, 23 Oct 2021 15:18:10 +0800 Subject: [PATCH 14/18] test(listx): add listx remove --- pkg/structure/listx/listx_test.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/pkg/structure/listx/listx_test.go b/pkg/structure/listx/listx_test.go index bc34617..b1feaa1 100644 --- a/pkg/structure/listx/listx_test.go +++ b/pkg/structure/listx/listx_test.go @@ -204,3 +204,25 @@ func TestListx_Range(t *testing.T) { _, err = list.Range(6, -1) require.Error(t, err) } + +func TestListx_Remove(t *testing.T) { + list := NewListXSingle() + list.RPush("a", "b", "c", "c", "e") + + count, up := list.Remove("c", -2) + require.Equal(t, count, 2) + require.Equal(t, int(up), 34) + + res, _ := list.LPop(list.Length()) + require.Equal(t, res, []string{"a", "b", "e"}) + + list = NewListXSingle() + list.RPush("a", "b", "c", "c", "e") + + count, up = list.Remove("b", 1) + require.Equal(t, count, 1) + require.Equal(t, int(up), 17) + + res, _ = list.LPop(list.Length()) + require.Equal(t, res, []string{"a", "c", "c", "e"}) +} From f15792032a96beb31c42ecdcb48e287e0d970db7 Mon Sep 17 00:00:00 2001 From: bandl <1658002533@qq.com> Date: Sat, 23 Oct 2021 15:18:21 +0800 Subject: [PATCH 15/18] feat(dao): add listx dao --- storage/dao/dao.go | 204 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 204 insertions(+) diff --git a/storage/dao/dao.go b/storage/dao/dao.go index 9849ac2..2c61c06 100644 --- a/storage/dao/dao.go +++ b/storage/dao/dao.go @@ -5,6 +5,7 @@ import ( "gitee.com/timedb/wheatCache/pkg/lru" "gitee.com/timedb/wheatCache/pkg/proto" "gitee.com/timedb/wheatCache/pkg/structure" + "gitee.com/timedb/wheatCache/pkg/structure/listx" "gitee.com/timedb/wheatCache/pkg/structure/stringx" ) @@ -194,3 +195,206 @@ func (d *Dao) Setnx(key *proto.BaseKey, val string) error { } return nil } + +// listx + +func (d *Dao) LINdex(key *proto.BaseKey, index int32) (string, error) { + val, ok := d.lru.Get(key) + if !ok { + return "", errorx.KeyBaseIsNilErr() + } + + listVal, ok := val.(structure.ListXInterface) + if !ok { + return "", errorx.DaoTypeErr("listx") + } + return listVal.Index(int(index)) +} + +func (d *Dao) LLen(key *proto.BaseKey) (int32, error) { + val, ok := d.lru.Get(key) + if !ok { + return 0, errorx.KeyBaseIsNilErr() + } + + listVal, ok := val.(structure.ListXInterface) + if !ok { + return 0, errorx.DaoTypeErr("listx") + } + + return int32(listVal.Length()), nil +} + +func (d *Dao) LPop(key *proto.BaseKey, count int32) ([]string, error) { + val, ok := d.lru.Get(key) + if !ok { + return nil, errorx.KeyBaseIsNilErr() + } + + listVal, ok := val.(structure.ListXInterface) + if !ok { + return nil, errorx.DaoTypeErr("listx") + } + + result, upLen := listVal.LPop(int(count)) + + d.lru.UpdateLruSize(upLen) + + return result, nil +} + +func (d *Dao) LPush(key *proto.BaseKey, values ...string) error { + val, ok := d.lru.Get(key) + if !ok { + list := listx.NewListXSingle() + list.LPush(values...) + return d.lru.Add(key, list) + } + + listVal, ok := val.(structure.ListXInterface) + if !ok { + return errorx.DaoTypeErr("listx") + } + + upLen := listVal.LPush(values...) + d.lru.UpdateLruSize(upLen) + + return nil +} + +func (d *Dao) LPushX(key *proto.BaseKey, values ...string) error { + val, ok := d.lru.Get(key) + if !ok { + return errorx.KeyBaseIsNilErr() + } + + listVal, ok := val.(structure.ListXInterface) + if !ok { + return errorx.DaoTypeErr("listx") + } + + upLen := listVal.LPush(values...) + d.lru.UpdateLruSize(upLen) + + return nil +} + +func (d *Dao) LRange(key *proto.BaseKey, start, end int32) ([]string, error) { + val, ok := d.lru.Get(key) + if !ok { + return nil, errorx.KeyBaseIsNilErr() + } + + listVal, ok := val.(structure.ListXInterface) + if !ok { + return nil, errorx.DaoTypeErr("listx") + } + + return listVal.Range(int(start), int(end)) +} + +func (d *Dao) LRemove(key *proto.BaseKey, count int32, value string) (int, error) { + val, ok := d.lru.Get(key) + if !ok { + return 0, errorx.KeyBaseIsNilErr() + } + + listVal, ok := val.(structure.ListXInterface) + if !ok { + return 0, errorx.DaoTypeErr("listx") + } + + remCount, upLen := listVal.Remove(value, int(count)) + d.lru.UpdateLruSize(upLen) + + return remCount, nil +} + +func (d *Dao) LSet(key *proto.BaseKey, index int32, value string) error { + val, ok := d.lru.Get(key) + if !ok { + return errorx.KeyBaseIsNilErr() + } + + listVal, ok := val.(structure.ListXInterface) + if !ok { + return errorx.DaoTypeErr("listx") + } + + upLen, err := listVal.Insert(int(index), false, value) + d.lru.UpdateLruSize(upLen) + return err +} + +func (d *Dao) RPop(key *proto.BaseKey, count int32) ([]string, error) { + val, ok := d.lru.Get(key) + if !ok { + return nil, errorx.KeyBaseIsNilErr() + } + + listVal, ok := val.(structure.ListXInterface) + if !ok { + return nil, errorx.DaoTypeErr("listx") + } + + result, upLen := listVal.RPop(int(count)) + + d.lru.UpdateLruSize(upLen) + + return result, nil +} + +func (d *Dao) LTrim(key *proto.BaseKey, start, end int32) error { + val, ok := d.lru.Get(key) + if !ok { + return errorx.KeyBaseIsNilErr() + } + + listVal, ok := val.(structure.ListXInterface) + if !ok { + return errorx.DaoTypeErr("listx") + } + + upLen, err := listVal.Slice(int(start), int(end)) + if err != nil { + return err + } + d.lru.UpdateLruSize(upLen) + return nil +} + +func (d *Dao) RPush(key *proto.BaseKey, values ...string) error { + val, ok := d.lru.Get(key) + if !ok { + list := listx.NewListXSingle() + list.RPush(values...) + return d.lru.Add(key, list) + } + + listVal, ok := val.(structure.ListXInterface) + if !ok { + return errorx.DaoTypeErr("listx") + } + + upLen := listVal.RPush(values...) + d.lru.UpdateLruSize(upLen) + + return nil +} + +func (d *Dao) RPushX(key *proto.BaseKey, values ...string) error { + val, ok := d.lru.Get(key) + if !ok { + return errorx.KeyBaseIsNilErr() + } + + listVal, ok := val.(structure.ListXInterface) + if !ok { + return errorx.DaoTypeErr("listx") + } + + upLen := listVal.RPush(values...) + d.lru.UpdateLruSize(upLen) + + return nil +} From 6a63bdca84b0585728db773a0a9cf615b5b04cb5 Mon Sep 17 00:00:00 2001 From: bandl <1658002533@qq.com> Date: Sat, 23 Oct 2021 16:02:52 +0800 Subject: [PATCH 16/18] fix(stringx): ctx --- storage/server/single/listx.go | 52 ++++++++++++++++++++++++++++++++ storage/server/single/stringx.go | 4 +-- 2 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 storage/server/single/listx.go diff --git a/storage/server/single/listx.go b/storage/server/single/listx.go new file mode 100644 index 0000000..50ead28 --- /dev/null +++ b/storage/server/single/listx.go @@ -0,0 +1,52 @@ +package single + +import "gitee.com/timedb/wheatCache/pkg/proto" + +func (s *serverSingle) Lindex(ctx context.Context, request *proto.LindexRequest) (*proto.LindexResponse, error) { + panic("implement me") +} + +func (s *serverSingle) Llen(ctx context.Context, request *proto.LlenRequest) (*proto.LlenResponse, error) { + panic("implement me") +} + +func (s *serverSingle) Lpop(ctx context.Context, request *proto.LpopRequest) (*proto.LpopResponse, error) { + panic("implement me") +} + +func (s *serverSingle) Lpush(ctx context.Context, request *proto.LpushRequest) (*proto.LpushResponse, error) { + panic("implement me") +} + +func (s *serverSingle) Lpushx(ctx context.Context, request *proto.LpushxRequest) (*proto.LpushxResponse, error) { + panic("implement me") +} + +func (s *serverSingle) Lrange(ctx context.Context, request *proto.LrangeRequest) (*proto.LrangeResponse, error) { + panic("implement me") +} + +func (s *serverSingle) Lrem(ctx context.Context, request *proto.LremRequest) (*proto.LremResponse, error) { + panic("implement me") +} + +func (s *serverSingle) Lset(ctx context.Context, request *proto.LsetRequest) (*proto.LsetResponse, error) { + panic("implement me") +} + +func (s *serverSingle) Rpop(ctx context.Context, request *proto.RpopRequest) (*proto.RpopResponse, error) { + panic("implement me") +} + +func (s *serverSingle) Ltrim(ctx context.Context, request *proto.LtrimRequest) (*proto.LtrimResponse, error) { + panic("implement me") +} + +func (s *serverSingle) Rpush(ctx context.Context, request *proto.RpushRequest) (*proto.RpushResponse, error) { + panic("implement me") +} + +func (s *serverSingle) Rpushx(ctx context.Context, request *proto.RpushxRequest) (*proto.RpushxResponse, error) { + panic("implement me") +} + diff --git a/storage/server/single/stringx.go b/storage/server/single/stringx.go index 59cb73a..83be2b0 100644 --- a/storage/server/single/stringx.go +++ b/storage/server/single/stringx.go @@ -9,7 +9,7 @@ import ( ) func (s *serverSingle) Set( - cxt context.Context, + ctx context.Context, req *proto.SetRequest, ) (*proto.SetResponse, error) { @@ -20,7 +20,7 @@ func (s *serverSingle) Set( lruEvent := event.NewEvent(lru.OptionEventName) lruEvent.InitWaitEvent() lruEvent.SetValue(lru.WorkFuncEventKey, work) - s.lruProduce.Call(cxt, lruEvent) + s.lruProduce.Call(ctx, lruEvent) resp, err := lruEvent.StartWaitEvent(s.timeOut) if err != nil { return nil, err From e96f21399cc68c96e573052138cf8e9518299e01 Mon Sep 17 00:00:00 2001 From: bandl <1658002533@qq.com> Date: Sat, 23 Oct 2021 16:04:35 +0800 Subject: [PATCH 17/18] chore(proto): update proto --- pkg/proto/listx.pb.go | 51 ++++++++++++++++++++++++++----------------- protobuf/listx.proto | 1 + 2 files changed, 32 insertions(+), 20 deletions(-) diff --git a/pkg/proto/listx.pb.go b/pkg/proto/listx.pb.go index d35d853..d4753e0 100644 --- a/pkg/proto/listx.pb.go +++ b/pkg/proto/listx.pb.go @@ -885,6 +885,8 @@ type RpopResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + + Result []string `protobuf:"bytes,1,rep,name=result,proto3" json:"result,omitempty"` } func (x *RpopResponse) Reset() { @@ -919,6 +921,13 @@ func (*RpopResponse) Descriptor() ([]byte, []int) { return file_listx_proto_rawDescGZIP(), []int{17} } +func (x *RpopResponse) GetResult() []string { + if x != nil { + return x.Result + } + return nil +} + type LtrimRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -1266,26 +1275,28 @@ var file_listx_proto_rawDesc = []byte{ 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x4b, 0x65, 0x79, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x63, - 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x0e, 0x0a, 0x0c, 0x52, 0x70, 0x6f, 0x70, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x52, 0x0a, 0x0c, 0x4c, 0x74, 0x72, 0x69, 0x6d, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x08, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x4b, 0x65, 0x79, 0x52, 0x03, 0x6b, 0x65, 0x79, - 0x12, 0x14, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x72, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x05, 0x73, 0x74, 0x61, 0x72, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x65, 0x6e, 0x64, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x03, 0x65, 0x6e, 0x64, 0x22, 0x0f, 0x0a, 0x0d, 0x4c, 0x74, 0x72, 0x69, - 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x42, 0x0a, 0x0c, 0x52, 0x70, 0x75, - 0x73, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x03, 0x6b, 0x65, 0x79, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x4b, 0x65, 0x79, - 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, - 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x22, 0x0f, 0x0a, - 0x0d, 0x52, 0x70, 0x75, 0x73, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x43, - 0x0a, 0x0d, 0x52, 0x70, 0x75, 0x73, 0x68, 0x78, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, - 0x1a, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x42, - 0x61, 0x73, 0x65, 0x4b, 0x65, 0x79, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x76, - 0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x76, 0x61, 0x6c, - 0x75, 0x65, 0x73, 0x22, 0x10, 0x0a, 0x0e, 0x52, 0x70, 0x75, 0x73, 0x68, 0x78, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x0b, 0x5a, 0x09, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x26, 0x0a, 0x0c, 0x52, 0x70, 0x6f, 0x70, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x01, + 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x52, 0x0a, 0x0c, + 0x4c, 0x74, 0x72, 0x69, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x03, + 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x42, 0x61, 0x73, 0x65, + 0x4b, 0x65, 0x79, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x72, + 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x73, 0x74, 0x61, 0x72, 0x74, 0x12, 0x10, + 0x0a, 0x03, 0x65, 0x6e, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x65, 0x6e, 0x64, + 0x22, 0x0f, 0x0a, 0x0d, 0x4c, 0x74, 0x72, 0x69, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x22, 0x42, 0x0a, 0x0c, 0x52, 0x70, 0x75, 0x73, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x12, 0x1a, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, + 0x2e, 0x42, 0x61, 0x73, 0x65, 0x4b, 0x65, 0x79, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x16, 0x0a, + 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x73, 0x22, 0x0f, 0x0a, 0x0d, 0x52, 0x70, 0x75, 0x73, 0x68, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x43, 0x0a, 0x0d, 0x52, 0x70, 0x75, 0x73, 0x68, 0x78, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x4b, 0x65, 0x79, 0x52, 0x03, + 0x6b, 0x65, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, 0x02, 0x20, + 0x03, 0x28, 0x09, 0x52, 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x22, 0x10, 0x0a, 0x0e, 0x52, + 0x70, 0x75, 0x73, 0x68, 0x78, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x0b, 0x5a, + 0x09, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( diff --git a/protobuf/listx.proto b/protobuf/listx.proto index 2a2e01a..df3add8 100644 --- a/protobuf/listx.proto +++ b/protobuf/listx.proto @@ -80,6 +80,7 @@ message RpopRequest { } message RpopResponse { + repeated string result = 1; } message LtrimRequest { From 0b781a178ebac9937d6cd55bb28206effa900c00 Mon Sep 17 00:00:00 2001 From: bandl <1658002533@qq.com> Date: Sat, 23 Oct 2021 16:17:29 +0800 Subject: [PATCH 18/18] feat(listx): add storage listx option --- storage/server/single/listx.go | 261 +++++++++++++++++++++++++++++---- 1 file changed, 235 insertions(+), 26 deletions(-) diff --git a/storage/server/single/listx.go b/storage/server/single/listx.go index 50ead28..5f08284 100644 --- a/storage/server/single/listx.go +++ b/storage/server/single/listx.go @@ -1,52 +1,261 @@ package single -import "gitee.com/timedb/wheatCache/pkg/proto" +import ( + context "context" -func (s *serverSingle) Lindex(ctx context.Context, request *proto.LindexRequest) (*proto.LindexResponse, error) { - panic("implement me") + "gitee.com/timedb/wheatCache/pkg/event" + "gitee.com/timedb/wheatCache/pkg/lru" + "gitee.com/timedb/wheatCache/pkg/proto" +) + +func (s *serverSingle) Lindex( + ctx context.Context, + req *proto.LindexRequest, +) (*proto.LindexResponse, error) { + work := event.EventWorkFunc(func() (interface{}, error) { + return s.dao.LINdex(req.Key, req.Index) + }) + + lruEvent := event.NewEvent(lru.OptionEventName) + lruEvent.InitWaitEvent() + lruEvent.SetValue(lru.WorkFuncEventKey, work) + s.lruProduce.Call(ctx, lruEvent) + resp, err := lruEvent.StartWaitEvent(s.timeOut) + if err != nil { + return nil, err + } + + return &proto.LindexResponse{ + Result: resp.(string), + }, nil } -func (s *serverSingle) Llen(ctx context.Context, request *proto.LlenRequest) (*proto.LlenResponse, error) { - panic("implement me") +func (s *serverSingle) Llen( + ctx context.Context, + req *proto.LlenRequest, +) (*proto.LlenResponse, error) { + work := event.EventWorkFunc(func() (interface{}, error) { + return s.dao.LLen(req.Key) + }) + + lruEvent := event.NewEvent(lru.OptionEventName) + lruEvent.InitWaitEvent() + lruEvent.SetValue(lru.WorkFuncEventKey, work) + s.lruProduce.Call(ctx, lruEvent) + resp, err := lruEvent.StartWaitEvent(s.timeOut) + if err != nil { + return nil, err + } + + return &proto.LlenResponse{ + Length: resp.(int32), + }, nil } -func (s *serverSingle) Lpop(ctx context.Context, request *proto.LpopRequest) (*proto.LpopResponse, error) { - panic("implement me") +func (s *serverSingle) Lpop( + ctx context.Context, + request *proto.LpopRequest, +) (*proto.LpopResponse, error) { + work := event.EventWorkFunc(func() (interface{}, error) { + return s.dao.LPop(request.Key, request.Count) + }) + + lruEvent := event.NewEvent(lru.OptionEventName) + lruEvent.InitWaitEvent() + lruEvent.SetValue(lru.WorkFuncEventKey, work) + s.lruProduce.Call(ctx, lruEvent) + resp, err := lruEvent.StartWaitEvent(s.timeOut) + if err != nil { + return nil, err + } + + return &proto.LpopResponse{ + Results: resp.([]string), + }, nil } -func (s *serverSingle) Lpush(ctx context.Context, request *proto.LpushRequest) (*proto.LpushResponse, error) { - panic("implement me") +func (s *serverSingle) Lpush( + ctx context.Context, + req *proto.LpushRequest, +) (*proto.LpushResponse, error) { + work := event.EventWorkFunc(func() (interface{}, error) { + return nil, s.dao.LPush(req.Key, req.Values...) + }) + + lruEvent := event.NewEvent(lru.OptionEventName) + lruEvent.InitWaitEvent() + lruEvent.SetValue(lru.WorkFuncEventKey, work) + s.lruProduce.Call(ctx, lruEvent) + _, err := lruEvent.StartWaitEvent(s.timeOut) + if err != nil { + return nil, err + } + + return &proto.LpushResponse{}, nil } -func (s *serverSingle) Lpushx(ctx context.Context, request *proto.LpushxRequest) (*proto.LpushxResponse, error) { - panic("implement me") +func (s *serverSingle) Lpushx( + ctx context.Context, + req *proto.LpushxRequest, +) (*proto.LpushxResponse, error) { + work := event.EventWorkFunc(func() (interface{}, error) { + return nil, s.dao.LPush(req.Key, req.Values...) + }) + + lruEvent := event.NewEvent(lru.OptionEventName) + lruEvent.InitWaitEvent() + lruEvent.SetValue(lru.WorkFuncEventKey, work) + s.lruProduce.Call(ctx, lruEvent) + _, err := lruEvent.StartWaitEvent(s.timeOut) + if err != nil { + return nil, err + } + + return &proto.LpushxResponse{}, nil } -func (s *serverSingle) Lrange(ctx context.Context, request *proto.LrangeRequest) (*proto.LrangeResponse, error) { - panic("implement me") +func (s *serverSingle) Lrange( + ctx context.Context, + req *proto.LrangeRequest, +) (*proto.LrangeResponse, error) { + work := event.EventWorkFunc(func() (interface{}, error) { + return s.dao.LRange(req.Key, req.Start, req.End) + }) + + lruEvent := event.NewEvent(lru.OptionEventName) + lruEvent.InitWaitEvent() + lruEvent.SetValue(lru.WorkFuncEventKey, work) + s.lruProduce.Call(ctx, lruEvent) + resp, err := lruEvent.StartWaitEvent(s.timeOut) + if err != nil { + return nil, err + } + + return &proto.LrangeResponse{ + Values: resp.([]string), + }, nil } -func (s *serverSingle) Lrem(ctx context.Context, request *proto.LremRequest) (*proto.LremResponse, error) { - panic("implement me") +func (s *serverSingle) Lrem( + ctx context.Context, + req *proto.LremRequest, +) (*proto.LremResponse, error) { + work := event.EventWorkFunc(func() (interface{}, error) { + return s.dao.LRemove(req.Key, req.Count, req.Value) + }) + + lruEvent := event.NewEvent(lru.OptionEventName) + lruEvent.InitWaitEvent() + lruEvent.SetValue(lru.WorkFuncEventKey, work) + s.lruProduce.Call(ctx, lruEvent) + resp, err := lruEvent.StartWaitEvent(s.timeOut) + if err != nil { + return nil, err + } + + return &proto.LremResponse{ + Count: resp.(int32), + }, nil } -func (s *serverSingle) Lset(ctx context.Context, request *proto.LsetRequest) (*proto.LsetResponse, error) { - panic("implement me") +func (s *serverSingle) Lset( + ctx context.Context, + req *proto.LsetRequest, +) (*proto.LsetResponse, error) { + work := event.EventWorkFunc(func() (interface{}, error) { + return nil, s.dao.LSet(req.Key, req.Index, req.Value) + }) + + lruEvent := event.NewEvent(lru.OptionEventName) + lruEvent.InitWaitEvent() + lruEvent.SetValue(lru.WorkFuncEventKey, work) + s.lruProduce.Call(ctx, lruEvent) + _, err := lruEvent.StartWaitEvent(s.timeOut) + if err != nil { + return nil, err + } + + return &proto.LsetResponse{}, nil } -func (s *serverSingle) Rpop(ctx context.Context, request *proto.RpopRequest) (*proto.RpopResponse, error) { - panic("implement me") +func (s *serverSingle) Rpop( + ctx context.Context, + req *proto.RpopRequest, +) (*proto.RpopResponse, error) { + work := event.EventWorkFunc(func() (interface{}, error) { + return s.dao.RPop(req.Key, req.Count) + }) + + lruEvent := event.NewEvent(lru.OptionEventName) + lruEvent.InitWaitEvent() + lruEvent.SetValue(lru.WorkFuncEventKey, work) + s.lruProduce.Call(ctx, lruEvent) + resp, err := lruEvent.StartWaitEvent(s.timeOut) + if err != nil { + return nil, err + } + + return &proto.RpopResponse{ + Result: resp.([]string), + }, nil } -func (s *serverSingle) Ltrim(ctx context.Context, request *proto.LtrimRequest) (*proto.LtrimResponse, error) { - panic("implement me") +func (s *serverSingle) Ltrim( + ctx context.Context, + req *proto.LtrimRequest, +) (*proto.LtrimResponse, error) { + work := event.EventWorkFunc(func() (interface{}, error) { + return nil, s.dao.LTrim(req.Key, req.Start, req.End) + }) + + lruEvent := event.NewEvent(lru.OptionEventName) + lruEvent.InitWaitEvent() + lruEvent.SetValue(lru.WorkFuncEventKey, work) + s.lruProduce.Call(ctx, lruEvent) + _, err := lruEvent.StartWaitEvent(s.timeOut) + if err != nil { + return nil, err + } + + return &proto.LtrimResponse{}, nil } -func (s *serverSingle) Rpush(ctx context.Context, request *proto.RpushRequest) (*proto.RpushResponse, error) { - panic("implement me") +func (s *serverSingle) Rpush( + ctx context.Context, + req *proto.RpushRequest, +) (*proto.RpushResponse, error) { + work := event.EventWorkFunc(func() (interface{}, error) { + return nil, s.dao.RPush(req.Key, req.Values...) + }) + + lruEvent := event.NewEvent(lru.OptionEventName) + lruEvent.InitWaitEvent() + lruEvent.SetValue(lru.WorkFuncEventKey, work) + s.lruProduce.Call(ctx, lruEvent) + _, err := lruEvent.StartWaitEvent(s.timeOut) + if err != nil { + return nil, err + } + + return &proto.RpushResponse{}, nil } -func (s *serverSingle) Rpushx(ctx context.Context, request *proto.RpushxRequest) (*proto.RpushxResponse, error) { - panic("implement me") -} +func (s *serverSingle) Rpushx( + ctx context.Context, + req *proto.RpushxRequest, +) (*proto.RpushxResponse, error) { + work := event.EventWorkFunc(func() (interface{}, error) { + return nil, s.dao.RPushX(req.Key, req.Values...) + }) + lruEvent := event.NewEvent(lru.OptionEventName) + lruEvent.InitWaitEvent() + lruEvent.SetValue(lru.WorkFuncEventKey, work) + s.lruProduce.Call(ctx, lruEvent) + _, err := lruEvent.StartWaitEvent(s.timeOut) + if err != nil { + return nil, err + } + + return &proto.RpushxResponse{}, nil +}