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)
)
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 {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
@ -148,7 +35,7 @@ type CommendResponse struct {
func (x *CommendResponse) Reset() {
*x = CommendResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_storage_proto_msgTypes[2]
mi := &file_storage_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -161,7 +48,7 @@ func (x *CommendResponse) String() string {
func (*CommendResponse) ProtoMessage() {}
func (x *CommendResponse) ProtoReflect() protoreflect.Message {
mi := &file_storage_proto_msgTypes[2]
mi := &file_storage_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -174,7 +61,7 @@ func (x *CommendResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use CommendResponse.ProtoReflect.Descriptor instead.
func (*CommendResponse) Descriptor() ([]byte, []int) {
return file_storage_proto_rawDescGZIP(), []int{2}
return file_storage_proto_rawDescGZIP(), []int{0}
}
func (x *CommendResponse) GetResult() []string {
@ -188,23 +75,17 @@ 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, 0x22, 0x46,
0x0a, 0x04, 0x43, 0x6f, 0x6d, 0x6d, 0x12, 0x2f, 0x0a, 0x0b, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67,
0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x53, 0x74,
0x72, 0x69, 0x6e, 0x67, 0x78, 0x43, 0x6f, 0x6d, 0x6d, 0x48, 0x00, 0x52, 0x0a, 0x73, 0x74, 0x72,
0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6d, 0x6d, 0x42, 0x0d, 0x0a, 0x0b, 0x63, 0x6f, 0x6d, 0x6d, 0x5f,
0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x33, 0x0a, 0x0e, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e,
0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x21, 0x0a, 0x08, 0x63, 0x6f, 0x6d, 0x6d,
0x65, 0x6e, 0x64, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x05, 0x2e, 0x43, 0x6f, 0x6d,
0x6d, 0x52, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x64, 0x73, 0x22, 0x29, 0x0a, 0x0f, 0x43,
0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x64, 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, 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,
0x0d, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x78, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x29,
0x0a, 0x0f, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x64, 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, 0x32, 0x58, 0x0a, 0x0a, 0x43, 0x6f, 0x6d,
0x6d, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x24, 0x0a, 0x03, 0x47, 0x65, 0x74, 0x12, 0x0b,
0x2e, 0x47, 0x65, 0x74, 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, 0x12, 0x24, 0x0a,
0x03, 0x53, 0x65, 0x74, 0x12, 0x0b, 0x2e, 0x53, 0x65, 0x74, 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 (
@ -219,23 +100,22 @@ func file_storage_proto_rawDescGZIP() []byte {
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{}{
(*Comm)(nil), // 0: Comm
(*CommendRequest)(nil), // 1: CommendRequest
(*CommendResponse)(nil), // 2: CommendResponse
(*StringxComm)(nil), // 3: StringxComm
(*CommendResponse)(nil), // 0: CommendResponse
(*GetRequest)(nil), // 1: GetRequest
(*SetRequest)(nil), // 2: SetRequest
}
var file_storage_proto_depIdxs = []int32{
3, // 0: Comm.string_comm:type_name -> StringxComm
0, // 1: CommendRequest.commends:type_name -> Comm
1, // 2: CommServer.Commend:input_type -> CommendRequest
2, // 3: CommServer.Commend:output_type -> CommendResponse
3, // [3:4] is the sub-list for method output_type
2, // [2:3] is the sub-list for method input_type
2, // [2:2] is the sub-list for extension type_name
2, // [2:2] is the sub-list for extension extendee
0, // [0:2] is the sub-list for field type_name
1, // 0: CommServer.Get:input_type -> GetRequest
2, // 1: CommServer.Set:input_type -> SetRequest
0, // 2: CommServer.Get:output_type -> CommendResponse
0, // 3: CommServer.Set:output_type -> CommendResponse
2, // [2:4] is the sub-list for method output_type
0, // [0:2] 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
}
func init() { file_storage_proto_init() }
@ -246,30 +126,6 @@ func file_storage_proto_init() {
file_stringx_proto_init()
if !protoimpl.UnsafeEnabled {
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 {
case 0:
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{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_storage_proto_rawDesc,
NumEnums: 0,
NumMessages: 3,
NumMessages: 1,
NumExtensions: 0,
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.
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 {
@ -328,9 +182,18 @@ func NewCommServerClient(cc grpc.ClientConnInterface) CommServerClient {
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)
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 {
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.
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.
type UnimplementedCommServerServer struct {
}
func (*UnimplementedCommServerServer) Commend(context.Context, *CommendRequest) (*CommendResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Commend not implemented")
func (*UnimplementedCommServerServer) Get(context.Context, *GetRequest) (*CommendResponse, error) {
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) {
s.RegisterService(&_CommServer_serviceDesc, srv)
}
func _CommServer_Commend_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(CommendRequest)
func _CommServer_Get_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(CommServerServer).Commend(ctx, in)
return srv.(CommServerServer).Get(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/CommServer/Commend",
FullMethod: "/CommServer/Get",
}
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)
}
@ -377,8 +262,12 @@ var _CommServer_serviceDesc = grpc.ServiceDesc{
HandlerType: (*CommServerServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Commend",
Handler: _CommServer_Commend_Handler,
MethodName: "Get",
Handler: _CommServer_Get_Handler,
},
{
MethodName: "Set",
Handler: _CommServer_Set_Handler,
},
},
Streams: []grpc.StreamDesc{},

View File

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

View File

@ -1,15 +1,27 @@
package structure
const (
STRING_X = iota
LIST_X
SET_X
Z_SET_X
)
// SetComm 操作描述
type SetComm struct {
Typ int
Opt string
Params []string
type KeyBase struct {
}
func (k *KeyBase) SizeByte() int64 {
panic("not implemented") // TODO: Implement
}
// TODO RollBack 事务相关, V2 实现
func (k *KeyBase) RollBack() error {
panic("not implemented") // TODO: Implement
}
// 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
import "gitee.com/timedb/wheatCache/pkg/proto"
type CacheValue interface {
LengthByte() int64
}
type KeyBase interface {
type KeyBaseInterface interface {
SizeByte() int64
// TODO RollBack 事务相关, V2 实现
@ -16,3 +18,14 @@ type KeyBase interface {
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
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
import "gitee.com/timedb/wheatCache/pkg/structure"
type StringX struct {
structure.KeyBase
Value string
}

View File

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

View File

@ -2,19 +2,59 @@ package server
import (
context "context"
"errors"
"gitee.com/timedb/wheatCache/pkg/proto"
"gitee.com/timedb/wheatCache/pkg/structure/stringx"
)
type server struct{}
type server struct {
}
func NewServer() proto.CommServerServer {
ser := &server{}
return ser
}
func (s *server) Commend(
ctx context.Context,
req *proto.CommendRequest,
func (s *server) Get(
cxt context.Context,
req *proto.GetRequest,
) (*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
}