feat(stringx): add gen template

This commit is contained in:
bandl 2021-09-19 11:53:17 +08:00
parent c1ca0a499f
commit 81f85009ab
8 changed files with 305 additions and 298 deletions

View File

@ -24,119 +24,6 @@ const (
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
) )
type Comm struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// Types that are assignable to CommOption:
// *Comm_StringComm
CommOption isComm_CommOption `protobuf_oneof:"comm_option"`
}
func (x *Comm) Reset() {
*x = Comm{}
if protoimpl.UnsafeEnabled {
mi := &file_storage_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Comm) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Comm) ProtoMessage() {}
func (x *Comm) ProtoReflect() protoreflect.Message {
mi := &file_storage_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 Comm.ProtoReflect.Descriptor instead.
func (*Comm) Descriptor() ([]byte, []int) {
return file_storage_proto_rawDescGZIP(), []int{0}
}
func (m *Comm) GetCommOption() isComm_CommOption {
if m != nil {
return m.CommOption
}
return nil
}
func (x *Comm) GetStringComm() *StringxComm {
if x, ok := x.GetCommOption().(*Comm_StringComm); ok {
return x.StringComm
}
return nil
}
type isComm_CommOption interface {
isComm_CommOption()
}
type Comm_StringComm struct {
StringComm *StringxComm `protobuf:"bytes,1,opt,name=string_comm,json=stringComm,proto3,oneof"`
}
func (*Comm_StringComm) isComm_CommOption() {}
type CommendRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Commends *Comm `protobuf:"bytes,1,opt,name=commends,proto3" json:"commends,omitempty"`
}
func (x *CommendRequest) Reset() {
*x = CommendRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_storage_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *CommendRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*CommendRequest) ProtoMessage() {}
func (x *CommendRequest) ProtoReflect() protoreflect.Message {
mi := &file_storage_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 CommendRequest.ProtoReflect.Descriptor instead.
func (*CommendRequest) Descriptor() ([]byte, []int) {
return file_storage_proto_rawDescGZIP(), []int{1}
}
func (x *CommendRequest) GetCommends() *Comm {
if x != nil {
return x.Commends
}
return nil
}
type CommendResponse struct { type CommendResponse struct {
state protoimpl.MessageState state protoimpl.MessageState
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
@ -148,7 +35,7 @@ type CommendResponse struct {
func (x *CommendResponse) Reset() { func (x *CommendResponse) Reset() {
*x = CommendResponse{} *x = CommendResponse{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_storage_proto_msgTypes[2] mi := &file_storage_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@ -161,7 +48,7 @@ func (x *CommendResponse) String() string {
func (*CommendResponse) ProtoMessage() {} func (*CommendResponse) ProtoMessage() {}
func (x *CommendResponse) ProtoReflect() protoreflect.Message { func (x *CommendResponse) ProtoReflect() protoreflect.Message {
mi := &file_storage_proto_msgTypes[2] mi := &file_storage_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil { if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@ -174,7 +61,7 @@ func (x *CommendResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use CommendResponse.ProtoReflect.Descriptor instead. // Deprecated: Use CommendResponse.ProtoReflect.Descriptor instead.
func (*CommendResponse) Descriptor() ([]byte, []int) { func (*CommendResponse) Descriptor() ([]byte, []int) {
return file_storage_proto_rawDescGZIP(), []int{2} return file_storage_proto_rawDescGZIP(), []int{0}
} }
func (x *CommendResponse) GetResult() []string { func (x *CommendResponse) GetResult() []string {
@ -188,23 +75,17 @@ var File_storage_proto protoreflect.FileDescriptor
var file_storage_proto_rawDesc = []byte{ var file_storage_proto_rawDesc = []byte{
0x0a, 0x0d, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 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, 0x22, 0x46, 0x0d, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x78, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x29,
0x0a, 0x04, 0x43, 0x6f, 0x6d, 0x6d, 0x12, 0x2f, 0x0a, 0x0b, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x0a, 0x0f, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x53, 0x74, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28,
0x72, 0x69, 0x6e, 0x67, 0x78, 0x43, 0x6f, 0x6d, 0x6d, 0x48, 0x00, 0x52, 0x0a, 0x73, 0x74, 0x72, 0x09, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x32, 0x58, 0x0a, 0x0a, 0x43, 0x6f, 0x6d,
0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6d, 0x6d, 0x42, 0x0d, 0x0a, 0x0b, 0x63, 0x6f, 0x6d, 0x6d, 0x5f, 0x6d, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x24, 0x0a, 0x03, 0x47, 0x65, 0x74, 0x12, 0x0b,
0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x33, 0x0a, 0x0e, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x10, 0x2e, 0x43, 0x6f,
0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x21, 0x0a, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x6d, 0x6d, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x24, 0x0a,
0x65, 0x6e, 0x64, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x05, 0x2e, 0x43, 0x6f, 0x6d, 0x03, 0x53, 0x65, 0x74, 0x12, 0x0b, 0x2e, 0x53, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x6d, 0x52, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x64, 0x73, 0x22, 0x29, 0x0a, 0x0f, 0x43, 0x74, 0x1a, 0x10, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f,
0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x6e, 0x73, 0x65, 0x42, 0x0b, 0x5a, 0x09, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x32, 0x3a, 0x0a, 0x0a, 0x43, 0x6f, 0x6d, 0x6d, 0x53, 0x65,
0x72, 0x76, 0x65, 0x72, 0x12, 0x2c, 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x64, 0x12,
0x0f, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x1a, 0x10, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x64, 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 ( var (
@ -219,23 +100,22 @@ func file_storage_proto_rawDescGZIP() []byte {
return file_storage_proto_rawDescData return file_storage_proto_rawDescData
} }
var file_storage_proto_msgTypes = make([]protoimpl.MessageInfo, 3) var file_storage_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
var file_storage_proto_goTypes = []interface{}{ var file_storage_proto_goTypes = []interface{}{
(*Comm)(nil), // 0: Comm (*CommendResponse)(nil), // 0: CommendResponse
(*CommendRequest)(nil), // 1: CommendRequest (*GetRequest)(nil), // 1: GetRequest
(*CommendResponse)(nil), // 2: CommendResponse (*SetRequest)(nil), // 2: SetRequest
(*StringxComm)(nil), // 3: StringxComm
} }
var file_storage_proto_depIdxs = []int32{ var file_storage_proto_depIdxs = []int32{
3, // 0: Comm.string_comm:type_name -> StringxComm 1, // 0: CommServer.Get:input_type -> GetRequest
0, // 1: CommendRequest.commends:type_name -> Comm 2, // 1: CommServer.Set:input_type -> SetRequest
1, // 2: CommServer.Commend:input_type -> CommendRequest 0, // 2: CommServer.Get:output_type -> CommendResponse
2, // 3: CommServer.Commend:output_type -> CommendResponse 0, // 3: CommServer.Set:output_type -> CommendResponse
3, // [3:4] is the sub-list for method output_type 2, // [2:4] is the sub-list for method output_type
2, // [2:3] is the sub-list for method input_type 0, // [0:2] is the sub-list for method input_type
2, // [2:2] is the sub-list for extension type_name 0, // [0:0] is the sub-list for extension type_name
2, // [2:2] is the sub-list for extension extendee 0, // [0:0] is the sub-list for extension extendee
0, // [0:2] is the sub-list for field type_name 0, // [0:0] is the sub-list for field type_name
} }
func init() { file_storage_proto_init() } func init() { file_storage_proto_init() }
@ -246,30 +126,6 @@ func file_storage_proto_init() {
file_stringx_proto_init() file_stringx_proto_init()
if !protoimpl.UnsafeEnabled { if !protoimpl.UnsafeEnabled {
file_storage_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { file_storage_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Comm); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_storage_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*CommendRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_storage_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*CommendResponse); i { switch v := v.(*CommendResponse); i {
case 0: case 0:
return &v.state return &v.state
@ -282,16 +138,13 @@ func file_storage_proto_init() {
} }
} }
} }
file_storage_proto_msgTypes[0].OneofWrappers = []interface{}{
(*Comm_StringComm)(nil),
}
type x struct{} type x struct{}
out := protoimpl.TypeBuilder{ out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{ File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(), GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_storage_proto_rawDesc, RawDescriptor: file_storage_proto_rawDesc,
NumEnums: 0, NumEnums: 0,
NumMessages: 3, NumMessages: 1,
NumExtensions: 0, NumExtensions: 0,
NumServices: 1, NumServices: 1,
}, },
@ -317,7 +170,8 @@ const _ = grpc.SupportPackageIsVersion6
// //
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type CommServerClient interface { type CommServerClient interface {
Commend(ctx context.Context, in *CommendRequest, opts ...grpc.CallOption) (*CommendResponse, error) Get(ctx context.Context, in *GetRequest, opts ...grpc.CallOption) (*CommendResponse, error)
Set(ctx context.Context, in *SetRequest, opts ...grpc.CallOption) (*CommendResponse, error)
} }
type commServerClient struct { type commServerClient struct {
@ -328,9 +182,18 @@ func NewCommServerClient(cc grpc.ClientConnInterface) CommServerClient {
return &commServerClient{cc} return &commServerClient{cc}
} }
func (c *commServerClient) Commend(ctx context.Context, in *CommendRequest, opts ...grpc.CallOption) (*CommendResponse, error) { func (c *commServerClient) Get(ctx context.Context, in *GetRequest, opts ...grpc.CallOption) (*CommendResponse, error) {
out := new(CommendResponse) out := new(CommendResponse)
err := c.cc.Invoke(ctx, "/CommServer/Commend", in, out, opts...) err := c.cc.Invoke(ctx, "/CommServer/Get", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *commServerClient) Set(ctx context.Context, in *SetRequest, opts ...grpc.CallOption) (*CommendResponse, error) {
out := new(CommendResponse)
err := c.cc.Invoke(ctx, "/CommServer/Set", in, out, opts...)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -339,35 +202,57 @@ func (c *commServerClient) Commend(ctx context.Context, in *CommendRequest, opts
// CommServerServer is the server API for CommServer service. // CommServerServer is the server API for CommServer service.
type CommServerServer interface { type CommServerServer interface {
Commend(context.Context, *CommendRequest) (*CommendResponse, error) Get(context.Context, *GetRequest) (*CommendResponse, error)
Set(context.Context, *SetRequest) (*CommendResponse, error)
} }
// UnimplementedCommServerServer can be embedded to have forward compatible implementations. // UnimplementedCommServerServer can be embedded to have forward compatible implementations.
type UnimplementedCommServerServer struct { type UnimplementedCommServerServer struct {
} }
func (*UnimplementedCommServerServer) Commend(context.Context, *CommendRequest) (*CommendResponse, error) { func (*UnimplementedCommServerServer) Get(context.Context, *GetRequest) (*CommendResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Commend not implemented") return nil, status.Errorf(codes.Unimplemented, "method Get not implemented")
}
func (*UnimplementedCommServerServer) Set(context.Context, *SetRequest) (*CommendResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Set not implemented")
} }
func RegisterCommServerServer(s *grpc.Server, srv CommServerServer) { func RegisterCommServerServer(s *grpc.Server, srv CommServerServer) {
s.RegisterService(&_CommServer_serviceDesc, srv) s.RegisterService(&_CommServer_serviceDesc, srv)
} }
func _CommServer_Commend_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { func _CommServer_Get_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(CommendRequest) in := new(GetRequest)
if err := dec(in); err != nil { if err := dec(in); err != nil {
return nil, err return nil, err
} }
if interceptor == nil { if interceptor == nil {
return srv.(CommServerServer).Commend(ctx, in) return srv.(CommServerServer).Get(ctx, in)
} }
info := &grpc.UnaryServerInfo{ info := &grpc.UnaryServerInfo{
Server: srv, Server: srv,
FullMethod: "/CommServer/Commend", FullMethod: "/CommServer/Get",
} }
handler := func(ctx context.Context, req interface{}) (interface{}, error) { handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(CommServerServer).Commend(ctx, req.(*CommendRequest)) return srv.(CommServerServer).Get(ctx, req.(*GetRequest))
}
return interceptor(ctx, in, info, handler)
}
func _CommServer_Set_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(SetRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(CommServerServer).Set(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/CommServer/Set",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(CommServerServer).Set(ctx, req.(*SetRequest))
} }
return interceptor(ctx, in, info, handler) return interceptor(ctx, in, info, handler)
} }
@ -377,8 +262,12 @@ var _CommServer_serviceDesc = grpc.ServiceDesc{
HandlerType: (*CommServerServer)(nil), HandlerType: (*CommServerServer)(nil),
Methods: []grpc.MethodDesc{ Methods: []grpc.MethodDesc{
{ {
MethodName: "Commend", MethodName: "Get",
Handler: _CommServer_Commend_Handler, Handler: _CommServer_Get_Handler,
},
{
MethodName: "Set",
Handler: _CommServer_Set_Handler,
}, },
}, },
Streams: []grpc.StreamDesc{}, Streams: []grpc.StreamDesc{},

View File

@ -20,7 +20,7 @@ const (
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
) )
type Set struct { type SetRequest struct {
state protoimpl.MessageState state protoimpl.MessageState
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
@ -29,8 +29,8 @@ type Set struct {
Value string `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` Value string `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
} }
func (x *Set) Reset() { func (x *SetRequest) Reset() {
*x = Set{} *x = SetRequest{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_stringx_proto_msgTypes[0] mi := &file_stringx_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@ -38,13 +38,13 @@ func (x *Set) Reset() {
} }
} }
func (x *Set) String() string { func (x *SetRequest) String() string {
return protoimpl.X.MessageStringOf(x) return protoimpl.X.MessageStringOf(x)
} }
func (*Set) ProtoMessage() {} func (*SetRequest) ProtoMessage() {}
func (x *Set) ProtoReflect() protoreflect.Message { func (x *SetRequest) ProtoReflect() protoreflect.Message {
mi := &file_stringx_proto_msgTypes[0] mi := &file_stringx_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil { if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@ -56,26 +56,26 @@ func (x *Set) ProtoReflect() protoreflect.Message {
return mi.MessageOf(x) return mi.MessageOf(x)
} }
// Deprecated: Use Set.ProtoReflect.Descriptor instead. // Deprecated: Use SetRequest.ProtoReflect.Descriptor instead.
func (*Set) Descriptor() ([]byte, []int) { func (*SetRequest) Descriptor() ([]byte, []int) {
return file_stringx_proto_rawDescGZIP(), []int{0} return file_stringx_proto_rawDescGZIP(), []int{0}
} }
func (x *Set) GetKey() *BaseKey { func (x *SetRequest) GetKey() *BaseKey {
if x != nil { if x != nil {
return x.Key return x.Key
} }
return nil return nil
} }
func (x *Set) GetValue() string { func (x *SetRequest) GetValue() string {
if x != nil { if x != nil {
return x.Value return x.Value
} }
return "" return ""
} }
type Get struct { type GetRequest struct {
state protoimpl.MessageState state protoimpl.MessageState
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
@ -83,8 +83,8 @@ type Get struct {
Key *BaseKey `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` Key *BaseKey `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
} }
func (x *Get) Reset() { func (x *GetRequest) Reset() {
*x = Get{} *x = GetRequest{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_stringx_proto_msgTypes[1] mi := &file_stringx_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@ -92,13 +92,13 @@ func (x *Get) Reset() {
} }
} }
func (x *Get) String() string { func (x *GetRequest) String() string {
return protoimpl.X.MessageStringOf(x) return protoimpl.X.MessageStringOf(x)
} }
func (*Get) ProtoMessage() {} func (*GetRequest) ProtoMessage() {}
func (x *Get) ProtoReflect() protoreflect.Message { func (x *GetRequest) ProtoReflect() protoreflect.Message {
mi := &file_stringx_proto_msgTypes[1] mi := &file_stringx_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil { if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@ -110,31 +110,29 @@ func (x *Get) ProtoReflect() protoreflect.Message {
return mi.MessageOf(x) return mi.MessageOf(x)
} }
// Deprecated: Use Get.ProtoReflect.Descriptor instead. // Deprecated: Use GetRequest.ProtoReflect.Descriptor instead.
func (*Get) Descriptor() ([]byte, []int) { func (*GetRequest) Descriptor() ([]byte, []int) {
return file_stringx_proto_rawDescGZIP(), []int{1} return file_stringx_proto_rawDescGZIP(), []int{1}
} }
func (x *Get) GetKey() *BaseKey { func (x *GetRequest) GetKey() *BaseKey {
if x != nil { if x != nil {
return x.Key return x.Key
} }
return nil return nil
} }
type StringxComm struct { type AddRequest struct {
state protoimpl.MessageState state protoimpl.MessageState
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
// Types that are assignable to Comm: Key *BaseKey `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
// *StringxComm_Get Value int64 `protobuf:"varint,2,opt,name=value,proto3" json:"value,omitempty"`
// *StringxComm_Set
Comm isStringxComm_Comm `protobuf_oneof:"comm"`
} }
func (x *StringxComm) Reset() { func (x *AddRequest) Reset() {
*x = StringxComm{} *x = AddRequest{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_stringx_proto_msgTypes[2] mi := &file_stringx_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@ -142,13 +140,13 @@ func (x *StringxComm) Reset() {
} }
} }
func (x *StringxComm) String() string { func (x *AddRequest) String() string {
return protoimpl.X.MessageStringOf(x) return protoimpl.X.MessageStringOf(x)
} }
func (*StringxComm) ProtoMessage() {} func (*AddRequest) ProtoMessage() {}
func (x *StringxComm) ProtoReflect() protoreflect.Message { func (x *AddRequest) ProtoReflect() protoreflect.Message {
mi := &file_stringx_proto_msgTypes[2] mi := &file_stringx_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil { if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@ -160,65 +158,92 @@ func (x *StringxComm) ProtoReflect() protoreflect.Message {
return mi.MessageOf(x) return mi.MessageOf(x)
} }
// Deprecated: Use StringxComm.ProtoReflect.Descriptor instead. // Deprecated: Use AddRequest.ProtoReflect.Descriptor instead.
func (*StringxComm) Descriptor() ([]byte, []int) { func (*AddRequest) Descriptor() ([]byte, []int) {
return file_stringx_proto_rawDescGZIP(), []int{2} return file_stringx_proto_rawDescGZIP(), []int{2}
} }
func (m *StringxComm) GetComm() isStringxComm_Comm { func (x *AddRequest) GetKey() *BaseKey {
if m != nil { if x != nil {
return m.Comm return x.Key
} }
return nil return nil
} }
func (x *StringxComm) GetGet() *Set { func (x *AddRequest) GetValue() int64 {
if x, ok := x.GetComm().(*StringxComm_Get); ok { if x != nil {
return x.Get return x.Value
}
return 0
}
type RedceRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Key *BaseKey `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
}
func (x *RedceRequest) Reset() {
*x = RedceRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_stringx_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *RedceRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*RedceRequest) ProtoMessage() {}
func (x *RedceRequest) ProtoReflect() protoreflect.Message {
mi := &file_stringx_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 RedceRequest.ProtoReflect.Descriptor instead.
func (*RedceRequest) Descriptor() ([]byte, []int) {
return file_stringx_proto_rawDescGZIP(), []int{3}
}
func (x *RedceRequest) GetKey() *BaseKey {
if x != nil {
return x.Key
} }
return nil return nil
} }
func (x *StringxComm) GetSet() *Get {
if x, ok := x.GetComm().(*StringxComm_Set); ok {
return x.Set
}
return nil
}
type isStringxComm_Comm interface {
isStringxComm_Comm()
}
type StringxComm_Get struct {
Get *Set `protobuf:"bytes,1,opt,name=get,proto3,oneof"`
}
type StringxComm_Set struct {
Set *Get `protobuf:"bytes,2,opt,name=set,proto3,oneof"`
}
func (*StringxComm_Get) isStringxComm_Comm() {}
func (*StringxComm_Set) isStringxComm_Comm() {}
var File_stringx_proto protoreflect.FileDescriptor var File_stringx_proto protoreflect.FileDescriptor
var file_stringx_proto_rawDesc = []byte{ var file_stringx_proto_rawDesc = []byte{
0x0a, 0x0d, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x78, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0a, 0x0d, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x78, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a,
0x0a, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x37, 0x0a, 0x03, 0x53, 0x0a, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x3e, 0x0a, 0x0a, 0x53,
0x65, 0x74, 0x12, 0x1a, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x03, 0x6b, 0x65, 0x79,
0x08, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x4b, 0x65, 0x79, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x4b, 0x65, 0x79,
0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02,
0x61, 0x6c, 0x75, 0x65, 0x22, 0x21, 0x0a, 0x03, 0x47, 0x65, 0x74, 0x12, 0x1a, 0x0a, 0x03, 0x6b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x28, 0x0a, 0x0a, 0x47,
0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x4b, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x03, 0x6b, 0x65, 0x79,
0x65, 0x79, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x22, 0x49, 0x0a, 0x0b, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x4b, 0x65, 0x79,
0x67, 0x78, 0x43, 0x6f, 0x6d, 0x6d, 0x12, 0x18, 0x0a, 0x03, 0x67, 0x65, 0x74, 0x18, 0x01, 0x20, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x22, 0x3e, 0x0a, 0x0a, 0x41, 0x64, 0x64, 0x52, 0x65, 0x71, 0x75,
0x01, 0x28, 0x0b, 0x32, 0x04, 0x2e, 0x53, 0x65, 0x74, 0x48, 0x00, 0x52, 0x03, 0x67, 0x65, 0x74, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b,
0x12, 0x18, 0x0a, 0x03, 0x73, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x04, 0x2e, 0x32, 0x08, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x4b, 0x65, 0x79, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12,
0x47, 0x65, 0x74, 0x48, 0x00, 0x52, 0x03, 0x73, 0x65, 0x74, 0x42, 0x06, 0x0a, 0x04, 0x63, 0x6f, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05,
0x6d, 0x6d, 0x42, 0x0b, 0x5a, 0x09, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x2a, 0x0a, 0x0c, 0x52, 0x65, 0x64, 0x63, 0x65, 0x52, 0x65,
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 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, 0x42, 0x0b, 0x5a, 0x09, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
} }
var ( var (
@ -233,18 +258,19 @@ func file_stringx_proto_rawDescGZIP() []byte {
return file_stringx_proto_rawDescData return file_stringx_proto_rawDescData
} }
var file_stringx_proto_msgTypes = make([]protoimpl.MessageInfo, 3) var file_stringx_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
var file_stringx_proto_goTypes = []interface{}{ var file_stringx_proto_goTypes = []interface{}{
(*Set)(nil), // 0: Set (*SetRequest)(nil), // 0: SetRequest
(*Get)(nil), // 1: Get (*GetRequest)(nil), // 1: GetRequest
(*StringxComm)(nil), // 2: StringxComm (*AddRequest)(nil), // 2: AddRequest
(*BaseKey)(nil), // 3: BaseKey (*RedceRequest)(nil), // 3: RedceRequest
(*BaseKey)(nil), // 4: BaseKey
} }
var file_stringx_proto_depIdxs = []int32{ var file_stringx_proto_depIdxs = []int32{
3, // 0: Set.key:type_name -> BaseKey 4, // 0: SetRequest.key:type_name -> BaseKey
3, // 1: Get.key:type_name -> BaseKey 4, // 1: GetRequest.key:type_name -> BaseKey
0, // 2: StringxComm.get:type_name -> Set 4, // 2: AddRequest.key:type_name -> BaseKey
1, // 3: StringxComm.set:type_name -> Get 4, // 3: RedceRequest.key:type_name -> BaseKey
4, // [4:4] is the sub-list for method output_type 4, // [4:4] is the sub-list for method output_type
4, // [4:4] is the sub-list for method input_type 4, // [4:4] is the sub-list for method input_type
4, // [4:4] is the sub-list for extension type_name 4, // [4:4] is the sub-list for extension type_name
@ -260,7 +286,7 @@ func file_stringx_proto_init() {
file_base_proto_init() file_base_proto_init()
if !protoimpl.UnsafeEnabled { if !protoimpl.UnsafeEnabled {
file_stringx_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { file_stringx_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Set); i { switch v := v.(*SetRequest); i {
case 0: case 0:
return &v.state return &v.state
case 1: case 1:
@ -272,7 +298,7 @@ func file_stringx_proto_init() {
} }
} }
file_stringx_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { file_stringx_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Get); i { switch v := v.(*GetRequest); i {
case 0: case 0:
return &v.state return &v.state
case 1: case 1:
@ -284,7 +310,19 @@ func file_stringx_proto_init() {
} }
} }
file_stringx_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { file_stringx_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*StringxComm); i { switch v := v.(*AddRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_stringx_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*RedceRequest); i {
case 0: case 0:
return &v.state return &v.state
case 1: case 1:
@ -296,17 +334,13 @@ func file_stringx_proto_init() {
} }
} }
} }
file_stringx_proto_msgTypes[2].OneofWrappers = []interface{}{
(*StringxComm_Get)(nil),
(*StringxComm_Set)(nil),
}
type x struct{} type x struct{}
out := protoimpl.TypeBuilder{ out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{ File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(), GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_stringx_proto_rawDesc, RawDescriptor: file_stringx_proto_rawDesc,
NumEnums: 0, NumEnums: 0,
NumMessages: 3, NumMessages: 4,
NumExtensions: 0, NumExtensions: 0,
NumServices: 0, NumServices: 0,
}, },

View File

@ -1,15 +1,27 @@
package structure package structure
const ( type KeyBase struct {
STRING_X = iota }
LIST_X
SET_X func (k *KeyBase) SizeByte() int64 {
Z_SET_X panic("not implemented") // TODO: Implement
) }
// SetComm 操作描述 // TODO RollBack 事务相关, V2 实现
type SetComm struct { func (k *KeyBase) RollBack() error {
Typ int panic("not implemented") // TODO: Implement
Opt string }
Params []string
// Begin 事务相关, V2 实现
func (k *KeyBase) Begin() error {
panic("not implemented") // TODO: Implement
}
// Comment 事务相关, V2 实现
func (k *KeyBase) Comment() error {
panic("not implemented") // TODO: Implement
}
func (k *KeyBase) Encode() ([]byte, error) {
panic("not implemented") // TODO: Implement
} }

View File

@ -1,10 +1,12 @@
package structure package structure
import "gitee.com/timedb/wheatCache/pkg/proto"
type CacheValue interface { type CacheValue interface {
LengthByte() int64 LengthByte() int64
} }
type KeyBase interface { type KeyBaseInterface interface {
SizeByte() int64 SizeByte() int64
// TODO RollBack 事务相关, V2 实现 // TODO RollBack 事务相关, V2 实现
@ -16,3 +18,14 @@ type KeyBase interface {
Encode() ([]byte, error) Encode() ([]byte, error)
} }
type StringXInterface interface {
KeyBaseInterface
Set(*proto.SetRequest) ([]string, error)
Get(*proto.GetRequest) ([]string, error)
}
type ListXInterface interface {
KeyBaseInterface
LSet(*proto.SetRequest) ([]string, error)
}

View File

@ -1 +1,15 @@
package stringx package stringx
import "gitee.com/timedb/wheatCache/pkg/proto"
func (s *StringX) Set(req *proto.SetRequest) ([]string, error) {
s.Value = req.Value
return nil, nil
}
func (s *StringX) Get(req *proto.GetRequest) ([]string, error) {
result := make([]string, 0, 1)
result = append(result, s.Value)
return result, nil
}

View File

@ -1 +1,8 @@
package stringx package stringx
import "gitee.com/timedb/wheatCache/pkg/structure"
type StringX struct {
structure.KeyBase
Value string
}

View File

@ -10,6 +10,4 @@ message CommendResponse {
service CommServer { service CommServer {
rpc Get (GetRequest) returns (CommendResponse); rpc Get (GetRequest) returns (CommendResponse);
rpc Set (SetRequest) returns (CommendResponse); rpc Set (SetRequest) returns (CommendResponse);
rpc Add ()
} }

View File

@ -2,19 +2,59 @@ package server
import ( import (
context "context" context "context"
"errors"
"gitee.com/timedb/wheatCache/pkg/proto" "gitee.com/timedb/wheatCache/pkg/proto"
"gitee.com/timedb/wheatCache/pkg/structure/stringx"
) )
type server struct{} type server struct {
}
func NewServer() proto.CommServerServer { func NewServer() proto.CommServerServer {
ser := &server{} ser := &server{}
return ser return ser
} }
func (s *server) Commend( func (s *server) Get(
ctx context.Context, cxt context.Context,
req *proto.CommendRequest, req *proto.GetRequest,
) (*proto.CommendResponse, error) { ) (*proto.CommendResponse, error) {
return nil, nil
var value interface{}
switch value.(type) {
case *stringx.StringX:
default:
return nil, errors.New("awdwd")
}
result, err := value.(*stringx.StringX).Get(req)
if err != nil {
return nil, err
}
return &proto.CommendResponse{
Result: result,
}, nil
}
func (s *server) Set(
ctx context.Context,
req *proto.SetRequest,
) (*proto.CommendResponse, error) {
var value interface{}
switch value.(type) {
case *stringx.StringX:
default:
return nil, errors.New("awdwd")
}
result, err := value.(*stringx.StringX).Set(req)
if err != nil {
return nil, err
}
return &proto.CommendResponse{
Result: result,
}, nil
} }