forked from p53841790/wheat-cache
!72 feat-stringx-option
Merge pull request !72 from bandl/feat-stringx-option
This commit is contained in:
commit
3a4fc48f46
|
@ -30,8 +30,8 @@ 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, 0xf3,
|
||||
0x01, 0x0a, 0x0a, 0x43, 0x6f, 0x6d, 0x6d, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x20, 0x0a,
|
||||
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,
|
||||
|
@ -46,23 +46,42 @@ var file_storage_proto_rawDesc = []byte{
|
|||
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, 0x42, 0x0b, 0x5a, 0x09, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
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,
|
||||
}
|
||||
|
||||
var file_storage_proto_goTypes = []interface{}{
|
||||
(*SetRequest)(nil), // 0: SetRequest
|
||||
(*GetRequest)(nil), // 1: GetRequest
|
||||
(*AddRequest)(nil), // 2: AddRequest
|
||||
(*ReduceRequest)(nil), // 3: ReduceRequest
|
||||
(*SetbitRequest)(nil), // 4: SetbitRequest
|
||||
(*GetbitRequest)(nil), // 5: GetbitRequest
|
||||
(*SetResponse)(nil), // 6: SetResponse
|
||||
(*GetResponse)(nil), // 7: GetResponse
|
||||
(*AddResponse)(nil), // 8: AddResponse
|
||||
(*ReduceResponse)(nil), // 9: ReduceResponse
|
||||
(*SetbitResponse)(nil), // 10: SetbitResponse
|
||||
(*GetbitResponse)(nil), // 11: GetbitResponse
|
||||
(*SetRequest)(nil), // 0: SetRequest
|
||||
(*GetRequest)(nil), // 1: GetRequest
|
||||
(*AddRequest)(nil), // 2: AddRequest
|
||||
(*ReduceRequest)(nil), // 3: ReduceRequest
|
||||
(*SetbitRequest)(nil), // 4: SetbitRequest
|
||||
(*GetbitRequest)(nil), // 5: GetbitRequest
|
||||
(*GetrangeRequest)(nil), // 6: GetrangeRequest
|
||||
(*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
|
||||
}
|
||||
var file_storage_proto_depIdxs = []int32{
|
||||
0, // 0: CommServer.Set:input_type -> SetRequest
|
||||
|
@ -71,14 +90,22 @@ var file_storage_proto_depIdxs = []int32{
|
|||
3, // 3: CommServer.Reduce:input_type -> ReduceRequest
|
||||
4, // 4: CommServer.Setbit:input_type -> SetbitRequest
|
||||
5, // 5: CommServer.Getbit:input_type -> GetbitRequest
|
||||
6, // 6: CommServer.Set:output_type -> SetResponse
|
||||
7, // 7: CommServer.Get:output_type -> GetResponse
|
||||
8, // 8: CommServer.Add:output_type -> AddResponse
|
||||
9, // 9: CommServer.Reduce:output_type -> ReduceResponse
|
||||
10, // 10: CommServer.Setbit:output_type -> SetbitResponse
|
||||
11, // 11: CommServer.Getbit:output_type -> GetbitResponse
|
||||
6, // [6:12] is the sub-list for method output_type
|
||||
0, // [0:6] is the sub-list for method input_type
|
||||
6, // 6: CommServer.Getrange:input_type -> GetrangeRequest
|
||||
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
|
||||
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
|
||||
|
@ -127,6 +154,10 @@ type CommServerClient interface {
|
|||
Reduce(ctx context.Context, in *ReduceRequest, opts ...grpc.CallOption) (*ReduceResponse, error)
|
||||
Setbit(ctx context.Context, in *SetbitRequest, opts ...grpc.CallOption) (*SetbitResponse, error)
|
||||
Getbit(ctx context.Context, in *GetbitRequest, opts ...grpc.CallOption) (*GetbitResponse, error)
|
||||
Getrange(ctx context.Context, in *GetrangeRequest, opts ...grpc.CallOption) (*GetrangeResponse, error)
|
||||
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)
|
||||
}
|
||||
|
||||
type commServerClient struct {
|
||||
|
@ -191,6 +222,42 @@ func (c *commServerClient) Getbit(ctx context.Context, in *GetbitRequest, opts .
|
|||
return out, nil
|
||||
}
|
||||
|
||||
func (c *commServerClient) Getrange(ctx context.Context, in *GetrangeRequest, opts ...grpc.CallOption) (*GetrangeResponse, error) {
|
||||
out := new(GetrangeResponse)
|
||||
err := c.cc.Invoke(ctx, "/CommServer/Getrange", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *commServerClient) Getset(ctx context.Context, in *GetsetRequest, opts ...grpc.CallOption) (*GetsetResponse, error) {
|
||||
out := new(GetsetResponse)
|
||||
err := c.cc.Invoke(ctx, "/CommServer/Getset", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *commServerClient) Strlen(ctx context.Context, in *StrlenRequest, opts ...grpc.CallOption) (*StrlenResponse, error) {
|
||||
out := new(StrlenResponse)
|
||||
err := c.cc.Invoke(ctx, "/CommServer/Strlen", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *commServerClient) Setnx(ctx context.Context, in *SetnxRequest, opts ...grpc.CallOption) (*SetnxResponse, error) {
|
||||
out := new(SetnxResponse)
|
||||
err := c.cc.Invoke(ctx, "/CommServer/Setnx", 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)
|
||||
|
@ -199,6 +266,10 @@ type CommServerServer interface {
|
|||
Reduce(context.Context, *ReduceRequest) (*ReduceResponse, error)
|
||||
Setbit(context.Context, *SetbitRequest) (*SetbitResponse, error)
|
||||
Getbit(context.Context, *GetbitRequest) (*GetbitResponse, error)
|
||||
Getrange(context.Context, *GetrangeRequest) (*GetrangeResponse, error)
|
||||
Getset(context.Context, *GetsetRequest) (*GetsetResponse, error)
|
||||
Strlen(context.Context, *StrlenRequest) (*StrlenResponse, error)
|
||||
Setnx(context.Context, *SetnxRequest) (*SetnxResponse, error)
|
||||
}
|
||||
|
||||
// UnimplementedCommServerServer can be embedded to have forward compatible implementations.
|
||||
|
@ -223,6 +294,18 @@ func (*UnimplementedCommServerServer) Setbit(context.Context, *SetbitRequest) (*
|
|||
func (*UnimplementedCommServerServer) Getbit(context.Context, *GetbitRequest) (*GetbitResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Getbit not implemented")
|
||||
}
|
||||
func (*UnimplementedCommServerServer) Getrange(context.Context, *GetrangeRequest) (*GetrangeResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Getrange not implemented")
|
||||
}
|
||||
func (*UnimplementedCommServerServer) Getset(context.Context, *GetsetRequest) (*GetsetResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Getset not implemented")
|
||||
}
|
||||
func (*UnimplementedCommServerServer) Strlen(context.Context, *StrlenRequest) (*StrlenResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Strlen not implemented")
|
||||
}
|
||||
func (*UnimplementedCommServerServer) Setnx(context.Context, *SetnxRequest) (*SetnxResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Setnx not implemented")
|
||||
}
|
||||
|
||||
func RegisterCommServerServer(s *grpc.Server, srv CommServerServer) {
|
||||
s.RegisterService(&_CommServer_serviceDesc, srv)
|
||||
|
@ -336,6 +419,78 @@ func _CommServer_Getbit_Handler(srv interface{}, ctx context.Context, dec func(i
|
|||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _CommServer_Getrange_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetrangeRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(CommServerServer).Getrange(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/CommServer/Getrange",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(CommServerServer).Getrange(ctx, req.(*GetrangeRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _CommServer_Getset_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetsetRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(CommServerServer).Getset(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/CommServer/Getset",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(CommServerServer).Getset(ctx, req.(*GetsetRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _CommServer_Strlen_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(StrlenRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(CommServerServer).Strlen(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/CommServer/Strlen",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(CommServerServer).Strlen(ctx, req.(*StrlenRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _CommServer_Setnx_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(SetnxRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(CommServerServer).Setnx(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/CommServer/Setnx",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(CommServerServer).Setnx(ctx, req.(*SetnxRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
var _CommServer_serviceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "CommServer",
|
||||
HandlerType: (*CommServerServer)(nil),
|
||||
|
@ -364,6 +519,22 @@ var _CommServer_serviceDesc = grpc.ServiceDesc{
|
|||
MethodName: "Getbit",
|
||||
Handler: _CommServer_Getbit_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "Getrange",
|
||||
Handler: _CommServer_Getrange_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "Getset",
|
||||
Handler: _CommServer_Getset_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "Strlen",
|
||||
Handler: _CommServer_Strlen_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "Setnx",
|
||||
Handler: _CommServer_Setnx_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "storage.proto",
|
||||
|
|
|
@ -623,6 +623,405 @@ func (x *GetbitResponse) GetVal() bool {
|
|||
return false
|
||||
}
|
||||
|
||||
type GetrangeRequest struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
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 *GetrangeRequest) Reset() {
|
||||
*x = GetrangeRequest{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_stringx_proto_msgTypes[12]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *GetrangeRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetrangeRequest) ProtoMessage() {}
|
||||
|
||||
func (x *GetrangeRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_stringx_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 GetrangeRequest.ProtoReflect.Descriptor instead.
|
||||
func (*GetrangeRequest) Descriptor() ([]byte, []int) {
|
||||
return file_stringx_proto_rawDescGZIP(), []int{12}
|
||||
}
|
||||
|
||||
func (x *GetrangeRequest) GetKey() *BaseKey {
|
||||
if x != nil {
|
||||
return x.Key
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *GetrangeRequest) GetStart() int32 {
|
||||
if x != nil {
|
||||
return x.Start
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *GetrangeRequest) GetEnd() int32 {
|
||||
if x != nil {
|
||||
return x.End
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type GetrangeResponse struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Result string `protobuf:"bytes,2,opt,name=result,proto3" json:"result,omitempty"`
|
||||
}
|
||||
|
||||
func (x *GetrangeResponse) Reset() {
|
||||
*x = GetrangeResponse{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_stringx_proto_msgTypes[13]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *GetrangeResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetrangeResponse) ProtoMessage() {}
|
||||
|
||||
func (x *GetrangeResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_stringx_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 GetrangeResponse.ProtoReflect.Descriptor instead.
|
||||
func (*GetrangeResponse) Descriptor() ([]byte, []int) {
|
||||
return file_stringx_proto_rawDescGZIP(), []int{13}
|
||||
}
|
||||
|
||||
func (x *GetrangeResponse) GetResult() string {
|
||||
if x != nil {
|
||||
return x.Result
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type GetsetRequest struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Key *BaseKey `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
|
||||
Val string `protobuf:"bytes,2,opt,name=val,proto3" json:"val,omitempty"`
|
||||
}
|
||||
|
||||
func (x *GetsetRequest) Reset() {
|
||||
*x = GetsetRequest{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_stringx_proto_msgTypes[14]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *GetsetRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetsetRequest) ProtoMessage() {}
|
||||
|
||||
func (x *GetsetRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_stringx_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 GetsetRequest.ProtoReflect.Descriptor instead.
|
||||
func (*GetsetRequest) Descriptor() ([]byte, []int) {
|
||||
return file_stringx_proto_rawDescGZIP(), []int{14}
|
||||
}
|
||||
|
||||
func (x *GetsetRequest) GetKey() *BaseKey {
|
||||
if x != nil {
|
||||
return x.Key
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *GetsetRequest) GetVal() string {
|
||||
if x != nil {
|
||||
return x.Val
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type GetsetResponse struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Result string `protobuf:"bytes,2,opt,name=result,proto3" json:"result,omitempty"`
|
||||
}
|
||||
|
||||
func (x *GetsetResponse) Reset() {
|
||||
*x = GetsetResponse{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_stringx_proto_msgTypes[15]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *GetsetResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetsetResponse) ProtoMessage() {}
|
||||
|
||||
func (x *GetsetResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_stringx_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 GetsetResponse.ProtoReflect.Descriptor instead.
|
||||
func (*GetsetResponse) Descriptor() ([]byte, []int) {
|
||||
return file_stringx_proto_rawDescGZIP(), []int{15}
|
||||
}
|
||||
|
||||
func (x *GetsetResponse) GetResult() string {
|
||||
if x != nil {
|
||||
return x.Result
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type StrlenRequest struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Key *BaseKey `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
|
||||
}
|
||||
|
||||
func (x *StrlenRequest) Reset() {
|
||||
*x = StrlenRequest{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_stringx_proto_msgTypes[16]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *StrlenRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*StrlenRequest) ProtoMessage() {}
|
||||
|
||||
func (x *StrlenRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_stringx_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 StrlenRequest.ProtoReflect.Descriptor instead.
|
||||
func (*StrlenRequest) Descriptor() ([]byte, []int) {
|
||||
return file_stringx_proto_rawDescGZIP(), []int{16}
|
||||
}
|
||||
|
||||
func (x *StrlenRequest) GetKey() *BaseKey {
|
||||
if x != nil {
|
||||
return x.Key
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type StrlenResponse struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Length int32 `protobuf:"varint,1,opt,name=length,proto3" json:"length,omitempty"`
|
||||
}
|
||||
|
||||
func (x *StrlenResponse) Reset() {
|
||||
*x = StrlenResponse{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_stringx_proto_msgTypes[17]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *StrlenResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*StrlenResponse) ProtoMessage() {}
|
||||
|
||||
func (x *StrlenResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_stringx_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 StrlenResponse.ProtoReflect.Descriptor instead.
|
||||
func (*StrlenResponse) Descriptor() ([]byte, []int) {
|
||||
return file_stringx_proto_rawDescGZIP(), []int{17}
|
||||
}
|
||||
|
||||
func (x *StrlenResponse) GetLength() int32 {
|
||||
if x != nil {
|
||||
return x.Length
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type SetnxRequest struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Key *BaseKey `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
|
||||
Val string `protobuf:"bytes,2,opt,name=val,proto3" json:"val,omitempty"`
|
||||
}
|
||||
|
||||
func (x *SetnxRequest) Reset() {
|
||||
*x = SetnxRequest{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_stringx_proto_msgTypes[18]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *SetnxRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*SetnxRequest) ProtoMessage() {}
|
||||
|
||||
func (x *SetnxRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_stringx_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 SetnxRequest.ProtoReflect.Descriptor instead.
|
||||
func (*SetnxRequest) Descriptor() ([]byte, []int) {
|
||||
return file_stringx_proto_rawDescGZIP(), []int{18}
|
||||
}
|
||||
|
||||
func (x *SetnxRequest) GetKey() *BaseKey {
|
||||
if x != nil {
|
||||
return x.Key
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *SetnxRequest) GetVal() string {
|
||||
if x != nil {
|
||||
return x.Val
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type SetnxResponse struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
}
|
||||
|
||||
func (x *SetnxResponse) Reset() {
|
||||
*x = SetnxResponse{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_stringx_proto_msgTypes[19]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *SetnxResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*SetnxResponse) ProtoMessage() {}
|
||||
|
||||
func (x *SetnxResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_stringx_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 SetnxResponse.ProtoReflect.Descriptor instead.
|
||||
func (*SetnxResponse) Descriptor() ([]byte, []int) {
|
||||
return file_stringx_proto_rawDescGZIP(), []int{19}
|
||||
}
|
||||
|
||||
var File_stringx_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_stringx_proto_rawDesc = []byte{
|
||||
|
@ -665,8 +1064,33 @@ var file_stringx_proto_rawDesc = []byte{
|
|||
0x14, 0x0a, 0x05, 0x6f, 0x66, 0x66, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05,
|
||||
0x6f, 0x66, 0x66, 0x65, 0x72, 0x22, 0x22, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x62, 0x69, 0x74, 0x52,
|
||||
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x76, 0x61, 0x6c, 0x18, 0x02,
|
||||
0x20, 0x01, 0x28, 0x08, 0x52, 0x03, 0x76, 0x61, 0x6c, 0x42, 0x0b, 0x5a, 0x09, 0x70, 0x6b, 0x67,
|
||||
0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x20, 0x01, 0x28, 0x08, 0x52, 0x03, 0x76, 0x61, 0x6c, 0x22, 0x55, 0x0a, 0x0f, 0x47, 0x65, 0x74,
|
||||
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, 0x2a, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70,
|
||||
0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x02,
|
||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x3d, 0x0a, 0x0d,
|
||||
0x47, 0x65, 0x74, 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, 0x10, 0x0a, 0x03, 0x76, 0x61, 0x6c,
|
||||
0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x76, 0x61, 0x6c, 0x22, 0x28, 0x0a, 0x0e, 0x47,
|
||||
0x65, 0x74, 0x73, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a,
|
||||
0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72,
|
||||
0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x2b, 0x0a, 0x0d, 0x53, 0x74, 0x72, 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, 0x28, 0x0a, 0x0e, 0x53, 0x74, 0x72, 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, 0x3c, 0x0a, 0x0c,
|
||||
0x53, 0x65, 0x74, 0x6e, 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, 0x10, 0x0a, 0x03, 0x76, 0x61, 0x6c, 0x18,
|
||||
0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x76, 0x61, 0x6c, 0x22, 0x0f, 0x0a, 0x0d, 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,
|
||||
}
|
||||
|
||||
var (
|
||||
|
@ -681,34 +1105,46 @@ func file_stringx_proto_rawDescGZIP() []byte {
|
|||
return file_stringx_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_stringx_proto_msgTypes = make([]protoimpl.MessageInfo, 12)
|
||||
var file_stringx_proto_msgTypes = make([]protoimpl.MessageInfo, 20)
|
||||
var file_stringx_proto_goTypes = []interface{}{
|
||||
(*SetRequest)(nil), // 0: SetRequest
|
||||
(*SetResponse)(nil), // 1: SetResponse
|
||||
(*GetRequest)(nil), // 2: GetRequest
|
||||
(*GetResponse)(nil), // 3: GetResponse
|
||||
(*AddRequest)(nil), // 4: AddRequest
|
||||
(*AddResponse)(nil), // 5: AddResponse
|
||||
(*ReduceRequest)(nil), // 6: ReduceRequest
|
||||
(*ReduceResponse)(nil), // 7: ReduceResponse
|
||||
(*SetbitRequest)(nil), // 8: SetbitRequest
|
||||
(*SetbitResponse)(nil), // 9: SetbitResponse
|
||||
(*GetbitRequest)(nil), // 10: GetbitRequest
|
||||
(*GetbitResponse)(nil), // 11: GetbitResponse
|
||||
(*BaseKey)(nil), // 12: BaseKey
|
||||
(*SetRequest)(nil), // 0: SetRequest
|
||||
(*SetResponse)(nil), // 1: SetResponse
|
||||
(*GetRequest)(nil), // 2: GetRequest
|
||||
(*GetResponse)(nil), // 3: GetResponse
|
||||
(*AddRequest)(nil), // 4: AddRequest
|
||||
(*AddResponse)(nil), // 5: AddResponse
|
||||
(*ReduceRequest)(nil), // 6: ReduceRequest
|
||||
(*ReduceResponse)(nil), // 7: ReduceResponse
|
||||
(*SetbitRequest)(nil), // 8: SetbitRequest
|
||||
(*SetbitResponse)(nil), // 9: SetbitResponse
|
||||
(*GetbitRequest)(nil), // 10: GetbitRequest
|
||||
(*GetbitResponse)(nil), // 11: GetbitResponse
|
||||
(*GetrangeRequest)(nil), // 12: GetrangeRequest
|
||||
(*GetrangeResponse)(nil), // 13: GetrangeResponse
|
||||
(*GetsetRequest)(nil), // 14: GetsetRequest
|
||||
(*GetsetResponse)(nil), // 15: GetsetResponse
|
||||
(*StrlenRequest)(nil), // 16: StrlenRequest
|
||||
(*StrlenResponse)(nil), // 17: StrlenResponse
|
||||
(*SetnxRequest)(nil), // 18: SetnxRequest
|
||||
(*SetnxResponse)(nil), // 19: SetnxResponse
|
||||
(*BaseKey)(nil), // 20: BaseKey
|
||||
}
|
||||
var file_stringx_proto_depIdxs = []int32{
|
||||
12, // 0: SetRequest.key:type_name -> BaseKey
|
||||
12, // 1: GetRequest.key:type_name -> BaseKey
|
||||
12, // 2: AddRequest.key:type_name -> BaseKey
|
||||
12, // 3: ReduceRequest.key:type_name -> BaseKey
|
||||
12, // 4: SetbitRequest.key:type_name -> BaseKey
|
||||
12, // 5: GetbitRequest.key:type_name -> BaseKey
|
||||
6, // [6:6] is the sub-list for method output_type
|
||||
6, // [6:6] is the sub-list for method input_type
|
||||
6, // [6:6] is the sub-list for extension type_name
|
||||
6, // [6:6] is the sub-list for extension extendee
|
||||
0, // [0:6] is the sub-list for field type_name
|
||||
20, // 0: SetRequest.key:type_name -> BaseKey
|
||||
20, // 1: GetRequest.key:type_name -> BaseKey
|
||||
20, // 2: AddRequest.key:type_name -> BaseKey
|
||||
20, // 3: ReduceRequest.key:type_name -> BaseKey
|
||||
20, // 4: SetbitRequest.key:type_name -> BaseKey
|
||||
20, // 5: GetbitRequest.key:type_name -> BaseKey
|
||||
20, // 6: GetrangeRequest.key:type_name -> BaseKey
|
||||
20, // 7: GetsetRequest.key:type_name -> BaseKey
|
||||
20, // 8: StrlenRequest.key:type_name -> BaseKey
|
||||
20, // 9: SetnxRequest.key:type_name -> BaseKey
|
||||
10, // [10:10] is the sub-list for method output_type
|
||||
10, // [10:10] is the sub-list for method input_type
|
||||
10, // [10:10] is the sub-list for extension type_name
|
||||
10, // [10:10] is the sub-list for extension extendee
|
||||
0, // [0:10] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_stringx_proto_init() }
|
||||
|
@ -862,6 +1298,102 @@ func file_stringx_proto_init() {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
file_stringx_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*GetrangeRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_stringx_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*GetrangeResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_stringx_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*GetsetRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_stringx_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*GetsetResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_stringx_proto_msgTypes[16].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*StrlenRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_stringx_proto_msgTypes[17].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*StrlenResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_stringx_proto_msgTypes[18].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*SetnxRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_stringx_proto_msgTypes[19].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*SetnxResponse); 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{
|
||||
|
@ -869,7 +1401,7 @@ func file_stringx_proto_init() {
|
|||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_stringx_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 12,
|
||||
NumMessages: 20,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
|
|
|
@ -17,20 +17,32 @@ const (
|
|||
REDUCE
|
||||
SETBIT
|
||||
GETBIT
|
||||
GETRANGE
|
||||
GETSET
|
||||
STRLEN
|
||||
SETNX
|
||||
)
|
||||
|
||||
var CommKeyString = map[string]int{"set": STRING_X,
|
||||
"get": STRING_X,
|
||||
"add": STRING_X,
|
||||
"reduce": STRING_X,
|
||||
"setbit": STRING_X,
|
||||
"getbit": STRING_X,
|
||||
"get": STRING_X,
|
||||
"add": STRING_X,
|
||||
"reduce": STRING_X,
|
||||
"setbit": STRING_X,
|
||||
"getbit": STRING_X,
|
||||
"getrange": STRING_X,
|
||||
"getset": STRING_X,
|
||||
"strlen": STRING_X,
|
||||
"setnx": STRING_X,
|
||||
}
|
||||
|
||||
var CommKey = map[int]int{SET: STRING_X,
|
||||
GET: STRING_X,
|
||||
ADD: STRING_X,
|
||||
REDUCE: STRING_X,
|
||||
SETBIT: STRING_X,
|
||||
GETBIT: STRING_X,
|
||||
GET: STRING_X,
|
||||
ADD: STRING_X,
|
||||
REDUCE: STRING_X,
|
||||
SETBIT: STRING_X,
|
||||
GETBIT: STRING_X,
|
||||
GETRANGE: STRING_X,
|
||||
GETSET: STRING_X,
|
||||
STRLEN: STRING_X,
|
||||
SETNX: STRING_X,
|
||||
}
|
||||
|
|
|
@ -7,4 +7,8 @@ STRING_X:
|
|||
- add
|
||||
- reduce
|
||||
- setbit
|
||||
- getbit
|
||||
- getbit
|
||||
- getrange
|
||||
- getset
|
||||
- strlen
|
||||
- setnx
|
|
@ -21,4 +21,6 @@ type StringXInterface interface {
|
|||
Reduce(int32) (string, error)
|
||||
Setbit(int32, bool) UpdateLength
|
||||
Getbit(int32) (bool, error)
|
||||
Getrange(start, end int32) (string, error)
|
||||
GetLength() int
|
||||
}
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
package stringx
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"gitee.com/timedb/wheatCache/pkg/errorx"
|
||||
"gitee.com/timedb/wheatCache/pkg/structure"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type StringSingle struct {
|
||||
|
@ -17,7 +18,7 @@ func NewStringSingle() structure.StringXInterface {
|
|||
}
|
||||
|
||||
func (s *StringSingle) SizeByte() int64 {
|
||||
return int64(s.val.GetLength())
|
||||
return int64(s.val.GetSize())
|
||||
}
|
||||
|
||||
// RollBack TODO 事务相关, V2 实现
|
||||
|
@ -105,3 +106,15 @@ func (s *StringSingle) Getbit(offer int32) (bool, error) {
|
|||
|
||||
return b, err
|
||||
}
|
||||
|
||||
func (s *StringSingle) Getrange(start, end int32) (string, error) {
|
||||
b, err := s.val.SliceByString(int(start), int(end))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return string(b), nil
|
||||
}
|
||||
|
||||
func (s *StringSingle) GetLength() int {
|
||||
return s.val.GetLength()
|
||||
}
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
package stringx
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"gitee.com/timedb/wheatCache/pkg/structure"
|
||||
"github.com/stretchr/testify/require"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestStringSingle_Set(t *testing.T) {
|
||||
|
@ -80,3 +81,11 @@ func TestStringSingle_Getbit(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
require.Equal(t, res, false)
|
||||
}
|
||||
|
||||
func TestStringSingle_Getrange(t *testing.T) {
|
||||
s := NewStringSingle()
|
||||
s.Set("abcdefg")
|
||||
k, err := s.Getrange(0, 3)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "abc", k)
|
||||
}
|
||||
|
|
|
@ -3,9 +3,10 @@ package structure
|
|||
import (
|
||||
"bytes"
|
||||
"encoding/binary"
|
||||
"gitee.com/timedb/wheatCache/pkg/errorx"
|
||||
"math"
|
||||
"strconv"
|
||||
|
||||
"gitee.com/timedb/wheatCache/pkg/errorx"
|
||||
)
|
||||
|
||||
// Value 提供一个基础的 动态类型
|
||||
|
@ -28,6 +29,10 @@ func (v *Value) GetLength() int {
|
|||
return len(v.val)
|
||||
}
|
||||
|
||||
func (v *Value) GetSize() int {
|
||||
return v.length
|
||||
}
|
||||
|
||||
func (v *Value) GetDynamicType() DynamicType {
|
||||
return v.onType
|
||||
}
|
||||
|
@ -160,3 +165,17 @@ func (v *Value) GetByte(offset int) (bool, error) {
|
|||
|
||||
return false, errorx.New("the maximum length is exceeded")
|
||||
}
|
||||
|
||||
func (v *Value) SliceByString(start, end int) ([]byte, error) {
|
||||
if v.onType != DynamicString {
|
||||
return nil, errorx.New("not is string")
|
||||
}
|
||||
if start > end {
|
||||
return nil, errorx.New("the end cannot be greater than the beginning")
|
||||
}
|
||||
if end > v.length {
|
||||
return nil, errorx.New("the maximum index is exceeded, max index: %d", v.length)
|
||||
}
|
||||
|
||||
return v.val[start:end], nil
|
||||
}
|
||||
|
|
|
@ -15,4 +15,8 @@ service CommServer {
|
|||
rpc Reduce (ReduceRequest) returns (ReduceResponse);
|
||||
rpc Setbit (SetbitRequest) returns (SetbitResponse);
|
||||
rpc Getbit (GetbitRequest) returns (GetbitResponse);
|
||||
rpc Getrange (GetrangeRequest) returns (GetrangeResponse);
|
||||
rpc Getset (GetsetRequest) returns (GetsetResponse);
|
||||
rpc Strlen (StrlenRequest) returns (StrlenResponse);
|
||||
rpc Setnx (SetnxRequest) returns (SetnxResponse);
|
||||
}
|
|
@ -54,3 +54,38 @@ message GetbitRequest {
|
|||
message GetbitResponse {
|
||||
bool val = 2;
|
||||
}
|
||||
|
||||
message GetrangeRequest {
|
||||
BaseKey key = 1;
|
||||
int32 start = 2;
|
||||
int32 end = 3;
|
||||
}
|
||||
|
||||
message GetrangeResponse {
|
||||
string result = 2;
|
||||
}
|
||||
|
||||
message GetsetRequest {
|
||||
BaseKey key = 1;
|
||||
string val = 2;
|
||||
}
|
||||
|
||||
message GetsetResponse {
|
||||
string result = 2;
|
||||
}
|
||||
|
||||
message StrlenRequest {
|
||||
BaseKey key = 1;
|
||||
}
|
||||
|
||||
message StrlenResponse {
|
||||
int32 length = 1;
|
||||
}
|
||||
|
||||
message SetnxRequest {
|
||||
BaseKey key = 1;
|
||||
string val = 2;
|
||||
}
|
||||
|
||||
message SetnxResponse {
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ func NewDao(lru lru.CacheInterface) *Dao {
|
|||
}
|
||||
}
|
||||
|
||||
// stringx 相关的方法
|
||||
func (d *Dao) Set(key *proto.BaseKey, strVal string) (string, error) {
|
||||
value, ok := d.lru.Get(key)
|
||||
if ok {
|
||||
|
@ -133,3 +134,63 @@ func (d *Dao) GetBit(key *proto.BaseKey, offer int32) (bool, error) {
|
|||
}
|
||||
return strVal.Getbit(offer)
|
||||
}
|
||||
|
||||
func (d *Dao) Getrange(key *proto.BaseKey, start, end int32) (string, error) {
|
||||
value, lruOk := d.lru.Get(key)
|
||||
if !lruOk {
|
||||
return "", errorx.NotKeyErr(key.Key)
|
||||
}
|
||||
strVal, ok := value.(structure.StringXInterface)
|
||||
if !ok {
|
||||
return "", errorx.DaoTypeErr("stringx")
|
||||
}
|
||||
|
||||
return strVal.Getrange(start, end)
|
||||
}
|
||||
|
||||
func (d *Dao) Getset(key *proto.BaseKey, value string) (string, error) {
|
||||
val, ok := d.lru.Get(key)
|
||||
if !ok {
|
||||
return "", errorx.NotKeyErr(key.Key)
|
||||
}
|
||||
|
||||
strVal, ok := val.(structure.StringXInterface)
|
||||
if !ok {
|
||||
return "", errorx.DaoTypeErr("stringx")
|
||||
}
|
||||
|
||||
oldValue := strVal.Get()
|
||||
|
||||
_, updateLength := strVal.Set(value)
|
||||
d.lru.UpdateLruSize(updateLength)
|
||||
return oldValue, nil
|
||||
}
|
||||
|
||||
func (d *Dao) Strlen(key *proto.BaseKey) (int32, error) {
|
||||
val, ok := d.lru.Get(key)
|
||||
if !ok {
|
||||
return 0, errorx.NotKeyErr(key.Key)
|
||||
}
|
||||
|
||||
strVal, ok := val.(structure.StringXInterface)
|
||||
if !ok {
|
||||
return 0, errorx.DaoTypeErr("stringx")
|
||||
}
|
||||
|
||||
return int32(strVal.GetLength()), nil
|
||||
}
|
||||
|
||||
func (d *Dao) Setnx(key *proto.BaseKey, val string) error {
|
||||
_, ok := d.lru.Get(key)
|
||||
if ok {
|
||||
return errorx.New("the key already exists")
|
||||
}
|
||||
|
||||
strValue := stringx.NewStringSingle()
|
||||
strValue.Set(val)
|
||||
err := d.lru.Add(key, strValue)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
package single
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gitee.com/timedb/wheatCache/pkg/event"
|
||||
"gitee.com/timedb/wheatCache/pkg/lru"
|
||||
"gitee.com/timedb/wheatCache/pkg/proto"
|
||||
"gitee.com/timedb/wheatCache/storage/dao"
|
||||
"github.com/spf13/viper"
|
||||
"time"
|
||||
)
|
||||
|
||||
type serverSingle struct {
|
||||
|
@ -16,7 +18,7 @@ type serverSingle struct {
|
|||
dao *dao.Dao
|
||||
}
|
||||
|
||||
func NewServer() *serverSingle {
|
||||
func NewServer() proto.CommServerServer {
|
||||
oneSingleServer.Do(func() {
|
||||
timeOut := viper.GetInt("storage.timeOut")
|
||||
if timeOut == 0 {
|
||||
|
|
|
@ -2,6 +2,7 @@ package single
|
|||
|
||||
import (
|
||||
context "context"
|
||||
|
||||
"gitee.com/timedb/wheatCache/pkg/event"
|
||||
"gitee.com/timedb/wheatCache/pkg/lru"
|
||||
"gitee.com/timedb/wheatCache/pkg/proto"
|
||||
|
@ -132,3 +133,85 @@ func (s *serverSingle) Getbit(
|
|||
Val: flag.(bool),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *serverSingle) Getrange(
|
||||
ctx context.Context,
|
||||
req *proto.GetrangeRequest,
|
||||
) (*proto.GetrangeResponse, error) {
|
||||
work := event.EventWorkFunc(func() (interface{}, error) {
|
||||
return s.dao.Getrange(req.Key, req.Start, req.End)
|
||||
})
|
||||
|
||||
lruEvent := event.NewEvent(lru.OptionEventName)
|
||||
lruEvent.InitWaitEvent()
|
||||
lruEvent.SetValue(lru.WorkFuncEventKey, work)
|
||||
s.lruProduce.Call(ctx, lruEvent)
|
||||
flag, err := lruEvent.StartWaitEvent(s.timeOut)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &proto.GetrangeResponse{
|
||||
Result: flag.(string),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *serverSingle) Getset(
|
||||
ctx context.Context,
|
||||
req *proto.GetsetRequest,
|
||||
) (*proto.GetsetResponse, error) {
|
||||
work := event.EventWorkFunc(func() (interface{}, error) {
|
||||
return s.dao.Getset(req.Key, req.Val)
|
||||
})
|
||||
|
||||
lruEvent := event.NewEvent(lru.OptionEventName)
|
||||
lruEvent.InitWaitEvent()
|
||||
lruEvent.SetValue(lru.WorkFuncEventKey, work)
|
||||
s.lruProduce.Call(ctx, lruEvent)
|
||||
result, err := lruEvent.StartWaitEvent(s.timeOut)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &proto.GetsetResponse{
|
||||
Result: result.(string),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *serverSingle) Strlen(
|
||||
ctx context.Context,
|
||||
req *proto.StrlenRequest,
|
||||
) (*proto.StrlenResponse, error) {
|
||||
work := event.EventWorkFunc(func() (interface{}, error) {
|
||||
return s.dao.Strlen(req.Key)
|
||||
})
|
||||
|
||||
lruEvent := event.NewEvent(lru.OptionEventName)
|
||||
lruEvent.InitWaitEvent()
|
||||
lruEvent.SetValue(lru.WorkFuncEventKey, work)
|
||||
s.lruProduce.Call(ctx, lruEvent)
|
||||
flag, err := lruEvent.StartWaitEvent(s.timeOut)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &proto.StrlenResponse{
|
||||
Length: flag.(int32),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *serverSingle) Setnx(
|
||||
ctx context.Context,
|
||||
req *proto.SetnxRequest,
|
||||
) (*proto.SetnxResponse, error) {
|
||||
work := event.EventWorkFunc(func() (interface{}, error) {
|
||||
return nil, s.dao.Setnx(req.Key, req.Val)
|
||||
})
|
||||
|
||||
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.SetnxResponse{}, nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue