forked from p93542168/wheat-cache
commit
63d6f66770
|
@ -29,7 +29,7 @@ func init() {
|
||||||
|
|
||||||
func setDefaultConfValue() {
|
func setDefaultConfValue() {
|
||||||
// 设置一些默认值
|
// 设置一些默认值
|
||||||
viper.Set("version", "base-01")
|
viper.SetDefault("version", "base-01")
|
||||||
}
|
}
|
||||||
|
|
||||||
func LoadConf(path string) error {
|
func LoadConf(path string) error {
|
||||||
|
|
5
makefile
5
makefile
|
@ -20,4 +20,7 @@ dev:
|
||||||
.PHONY: gen-struct
|
.PHONY: gen-struct
|
||||||
gen-struct:
|
gen-struct:
|
||||||
@python3 ./shell/make-struct.py
|
@python3 ./shell/make-struct.py
|
||||||
@gofmt -w $(BASE_PATH)/structure/generate/structure.gen.go
|
|
||||||
|
.PHONY: gen-protobuf
|
||||||
|
gen-protobuf:
|
||||||
|
@python3 ./shell/gen_protobuf.py
|
|
@ -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{},
|
||||||
|
|
|
@ -20,7 +20,7 @@ const (
|
||||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||||
)
|
)
|
||||||
|
|
||||||
type StringXSet 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 StringXSet 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 *StringXSet) Reset() {
|
func (x *SetRequest) Reset() {
|
||||||
*x = StringXSet{}
|
*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 *StringXSet) Reset() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *StringXSet) String() string {
|
func (x *SetRequest) String() string {
|
||||||
return protoimpl.X.MessageStringOf(x)
|
return protoimpl.X.MessageStringOf(x)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*StringXSet) ProtoMessage() {}
|
func (*SetRequest) ProtoMessage() {}
|
||||||
|
|
||||||
func (x *StringXSet) 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 *StringXSet) ProtoReflect() protoreflect.Message {
|
||||||
return mi.MessageOf(x)
|
return mi.MessageOf(x)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deprecated: Use StringXSet.ProtoReflect.Descriptor instead.
|
// Deprecated: Use SetRequest.ProtoReflect.Descriptor instead.
|
||||||
func (*StringXSet) Descriptor() ([]byte, []int) {
|
func (*SetRequest) Descriptor() ([]byte, []int) {
|
||||||
return file_stringx_proto_rawDescGZIP(), []int{0}
|
return file_stringx_proto_rawDescGZIP(), []int{0}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *StringXSet) 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 *StringXSet) GetValue() string {
|
func (x *SetRequest) GetValue() string {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.Value
|
return x.Value
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
type StringxGet 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 StringxGet 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 *StringxGet) Reset() {
|
func (x *GetRequest) Reset() {
|
||||||
*x = StringxGet{}
|
*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 *StringxGet) Reset() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *StringxGet) String() string {
|
func (x *GetRequest) String() string {
|
||||||
return protoimpl.X.MessageStringOf(x)
|
return protoimpl.X.MessageStringOf(x)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*StringxGet) ProtoMessage() {}
|
func (*GetRequest) ProtoMessage() {}
|
||||||
|
|
||||||
func (x *StringxGet) 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 *StringxGet) ProtoReflect() protoreflect.Message {
|
||||||
return mi.MessageOf(x)
|
return mi.MessageOf(x)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deprecated: Use StringxGet.ProtoReflect.Descriptor instead.
|
// Deprecated: Use GetRequest.ProtoReflect.Descriptor instead.
|
||||||
func (*StringxGet) Descriptor() ([]byte, []int) {
|
func (*GetRequest) Descriptor() ([]byte, []int) {
|
||||||
return file_stringx_proto_rawDescGZIP(), []int{1}
|
return file_stringx_proto_rawDescGZIP(), []int{1}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *StringxGet) 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 StringXComm:
|
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
|
|
||||||
StringXComm isStringxComm_StringXComm `protobuf_oneof:"string_x_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,67 +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) GetStringXComm() isStringxComm_StringXComm {
|
func (x *AddRequest) GetKey() *BaseKey {
|
||||||
if m != nil {
|
if x != nil {
|
||||||
return m.StringXComm
|
return x.Key
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *StringxComm) GetGet() *StringXSet {
|
func (x *AddRequest) GetValue() int64 {
|
||||||
if x, ok := x.GetStringXComm().(*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() *StringxGet {
|
|
||||||
if x, ok := x.GetStringXComm().(*StringxComm_Set); ok {
|
|
||||||
return x.Set
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
type isStringxComm_StringXComm interface {
|
|
||||||
isStringxComm_StringXComm()
|
|
||||||
}
|
|
||||||
|
|
||||||
type StringxComm_Get struct {
|
|
||||||
Get *StringXSet `protobuf:"bytes,1,opt,name=get,proto3,oneof"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type StringxComm_Set struct {
|
|
||||||
Set *StringxGet `protobuf:"bytes,2,opt,name=set,proto3,oneof"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (*StringxComm_Get) isStringxComm_StringXComm() {}
|
|
||||||
|
|
||||||
func (*StringxComm_Set) isStringxComm_StringXComm() {}
|
|
||||||
|
|
||||||
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, 0x3e, 0x0a, 0x0a, 0x53,
|
0x0a, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x3e, 0x0a, 0x0a, 0x53,
|
||||||
0x74, 0x72, 0x69, 0x6e, 0x67, 0x58, 0x53, 0x65, 0x74, 0x12, 0x1a, 0x0a, 0x03, 0x6b, 0x65, 0x79,
|
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,
|
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,
|
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, 0x53,
|
0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x28, 0x0a, 0x0a, 0x47,
|
||||||
0x74, 0x72, 0x69, 0x6e, 0x67, 0x78, 0x47, 0x65, 0x74, 0x12, 0x1a, 0x0a, 0x03, 0x6b, 0x65, 0x79,
|
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,
|
0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x4b, 0x65, 0x79,
|
||||||
0x52, 0x03, 0x6b, 0x65, 0x79, 0x22, 0x60, 0x0a, 0x0b, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x78,
|
0x52, 0x03, 0x6b, 0x65, 0x79, 0x22, 0x3e, 0x0a, 0x0a, 0x41, 0x64, 0x64, 0x52, 0x65, 0x71, 0x75,
|
||||||
0x43, 0x6f, 0x6d, 0x6d, 0x12, 0x1f, 0x0a, 0x03, 0x67, 0x65, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28,
|
0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b,
|
||||||
0x0b, 0x32, 0x0b, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x58, 0x53, 0x65, 0x74, 0x48, 0x00,
|
0x32, 0x08, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x4b, 0x65, 0x79, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12,
|
||||||
0x52, 0x03, 0x67, 0x65, 0x74, 0x12, 0x1f, 0x0a, 0x03, 0x73, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01,
|
0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05,
|
||||||
0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x78, 0x47, 0x65, 0x74, 0x48,
|
0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x2a, 0x0a, 0x0c, 0x52, 0x65, 0x64, 0x63, 0x65, 0x52, 0x65,
|
||||||
0x00, 0x52, 0x03, 0x73, 0x65, 0x74, 0x42, 0x0f, 0x0a, 0x0d, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67,
|
0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01,
|
||||||
0x5f, 0x78, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x42, 0x0b, 0x5a, 0x09, 0x70, 0x6b, 0x67, 0x2f, 0x70,
|
0x28, 0x0b, 0x32, 0x08, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x4b, 0x65, 0x79, 0x52, 0x03, 0x6b, 0x65,
|
||||||
0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
0x79, 0x42, 0x0b, 0x5a, 0x09, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06,
|
||||||
|
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -235,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{}{
|
||||||
(*StringXSet)(nil), // 0: StringXSet
|
(*SetRequest)(nil), // 0: SetRequest
|
||||||
(*StringxGet)(nil), // 1: StringxGet
|
(*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: StringXSet.key:type_name -> BaseKey
|
4, // 0: SetRequest.key:type_name -> BaseKey
|
||||||
3, // 1: StringxGet.key:type_name -> BaseKey
|
4, // 1: GetRequest.key:type_name -> BaseKey
|
||||||
0, // 2: StringxComm.get:type_name -> StringXSet
|
4, // 2: AddRequest.key:type_name -> BaseKey
|
||||||
1, // 3: StringxComm.set:type_name -> StringxGet
|
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
|
||||||
|
@ -262,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.(*StringXSet); i {
|
switch v := v.(*SetRequest); i {
|
||||||
case 0:
|
case 0:
|
||||||
return &v.state
|
return &v.state
|
||||||
case 1:
|
case 1:
|
||||||
|
@ -274,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.(*StringxGet); i {
|
switch v := v.(*GetRequest); i {
|
||||||
case 0:
|
case 0:
|
||||||
return &v.state
|
return &v.state
|
||||||
case 1:
|
case 1:
|
||||||
|
@ -286,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:
|
||||||
|
@ -298,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,
|
||||||
},
|
},
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
// Code generated by gen-struct. DO NOT EDIT.
|
||||||
|
// make gen-struct generated
|
||||||
|
|
||||||
|
package generate
|
||||||
|
|
||||||
|
const (
|
||||||
|
DEFAULT_KEY = iota
|
||||||
|
{% for key in keys %}
|
||||||
|
{{key}}
|
||||||
|
{% endfor %}
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
DEFAULT_COMM = iota
|
||||||
|
{% for key in sets %}
|
||||||
|
{{key}}
|
||||||
|
{% endfor %}
|
||||||
|
)
|
||||||
|
|
||||||
|
var CommKeyString = map[string]int {
|
||||||
|
{% for kmp in key_maps %}
|
||||||
|
{% for comm in kmp.val %}
|
||||||
|
"{{comm}}": {{kmp.key}},
|
||||||
|
{% endfor %}
|
||||||
|
{% endfor %}
|
||||||
|
}
|
||||||
|
|
||||||
|
var CommKey = map[int]int {
|
||||||
|
{% for kmp in key_maps %}
|
||||||
|
{% for comm in kmp.upper %}
|
||||||
|
{{comm}}: {{kmp.key}},
|
||||||
|
{% endfor %}
|
||||||
|
{% endfor %}
|
||||||
|
}
|
|
@ -5,37 +5,72 @@ package generate
|
||||||
|
|
||||||
const (
|
const (
|
||||||
DEFAULT_KEY = iota
|
DEFAULT_KEY = iota
|
||||||
|
|
||||||
STRING_X
|
STRING_X
|
||||||
|
|
||||||
|
LIST_X
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
DEFAULT_COMM = iota
|
DEFAULT_COMM = iota
|
||||||
|
|
||||||
SET_COMM
|
SET
|
||||||
|
|
||||||
GET_COMM
|
GET
|
||||||
|
|
||||||
ADD_COMM
|
ADD
|
||||||
|
|
||||||
REDUCE_COMM
|
REDUCE
|
||||||
|
|
||||||
SETBIT_COMM
|
SETBIT
|
||||||
|
|
||||||
GETBIT_COMM
|
GETBIT
|
||||||
|
|
||||||
|
L_SET
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var CommKey = map[string]int{
|
var CommKeyString = map[string]int {
|
||||||
|
|
||||||
|
|
||||||
"set": STRING_X,
|
"set": STRING_X,
|
||||||
|
|
||||||
"get": STRING_X,
|
"get": STRING_X,
|
||||||
|
|
||||||
"add": STRING_X,
|
"add": STRING_X,
|
||||||
|
|
||||||
"reduce": STRING_X,
|
"reduce": STRING_X,
|
||||||
|
|
||||||
"setbit": STRING_X,
|
"setbit": STRING_X,
|
||||||
|
|
||||||
"getbit": STRING_X,
|
"getbit": STRING_X,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"l_set": LIST_X,
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var CommKey = map[int]int {
|
||||||
|
|
||||||
|
|
||||||
|
SET: STRING_X,
|
||||||
|
|
||||||
|
GET: STRING_X,
|
||||||
|
|
||||||
|
ADD: STRING_X,
|
||||||
|
|
||||||
|
REDUCE: STRING_X,
|
||||||
|
|
||||||
|
SETBIT: STRING_X,
|
||||||
|
|
||||||
|
GETBIT: STRING_X,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
L_SET: LIST_X,
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -8,3 +8,10 @@ STRING_X:
|
||||||
- setbit
|
- setbit
|
||||||
- getbit
|
- getbit
|
||||||
|
|
||||||
|
LIST_X:
|
||||||
|
- l_set
|
||||||
|
- l_get
|
||||||
|
- l_add
|
||||||
|
- l_queue
|
||||||
|
- l_setbit
|
||||||
|
- l_getbit
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
package structure
|
package structure
|
||||||
|
|
||||||
|
import "gitee.com/timedb/wheatCache/pkg/proto"
|
||||||
|
|
||||||
type CacheValue interface {
|
type CacheValue interface {
|
||||||
LengthByte() int64
|
LengthByte() int64
|
||||||
}
|
}
|
||||||
|
|
||||||
type ParseComm func(comm interface{}) ([]string, error)
|
type KeyBaseInterface interface {
|
||||||
|
|
||||||
type CacheStruct interface {
|
|
||||||
SizeByte() int64
|
SizeByte() int64
|
||||||
|
|
||||||
// TODO RollBack 事务相关, V2 实现
|
// TODO RollBack 事务相关, V2 实现
|
||||||
|
@ -16,7 +16,16 @@ type CacheStruct interface {
|
||||||
// Comment 事务相关, V2 实现
|
// Comment 事务相关, V2 实现
|
||||||
Comment() error
|
Comment() error
|
||||||
|
|
||||||
ParseCommend(comm ParseComm) ([]string, error)
|
|
||||||
|
|
||||||
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)
|
||||||
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
}
|
||||||
|
|
|
@ -1 +1,8 @@
|
||||||
package stringx
|
package stringx
|
||||||
|
|
||||||
|
import "gitee.com/timedb/wheatCache/pkg/structure"
|
||||||
|
|
||||||
|
type StringX struct {
|
||||||
|
structure.KeyBase
|
||||||
|
Value string
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
syntax = "proto3";
|
||||||
|
import "base.proto";
|
||||||
|
option go_package = "pkg/proto";
|
||||||
|
|
||||||
|
message LSetRequest {
|
||||||
|
BaseKey key = 1;
|
||||||
|
}
|
||||||
|
message LGetRequest {
|
||||||
|
BaseKey key = 1;
|
||||||
|
}
|
||||||
|
message LAddRequest {
|
||||||
|
BaseKey key = 1;
|
||||||
|
}
|
||||||
|
message LQueueRequest {
|
||||||
|
BaseKey key = 1;
|
||||||
|
}
|
||||||
|
message LSetbitRequest {
|
||||||
|
BaseKey key = 1;
|
||||||
|
}
|
||||||
|
message LGetbitRequest {
|
||||||
|
BaseKey key = 1;
|
||||||
|
}
|
|
@ -3,22 +3,11 @@ syntax = "proto3";
|
||||||
option go_package = "pkg/proto";
|
option go_package = "pkg/proto";
|
||||||
import "stringx.proto";
|
import "stringx.proto";
|
||||||
|
|
||||||
message Comm {
|
|
||||||
oneof comm_option {
|
|
||||||
StringxComm string_comm = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
message CommendRequest {
|
|
||||||
Comm commends = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message CommendResponse {
|
message CommendResponse {
|
||||||
repeated string result = 1;
|
repeated string result = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
service CommServer {
|
service CommServer {
|
||||||
rpc Commend (CommendRequest) returns (CommendResponse);
|
rpc Get (GetRequest) returns (CommendResponse);
|
||||||
}
|
rpc Set (SetRequest) returns (CommendResponse);
|
||||||
|
}
|
||||||
|
|
|
@ -5,18 +5,27 @@ import "base.proto";
|
||||||
option go_package = "pkg/proto";
|
option go_package = "pkg/proto";
|
||||||
|
|
||||||
|
|
||||||
message StringXSet {
|
message SetRequest {
|
||||||
BaseKey key = 1;
|
BaseKey key = 1;
|
||||||
string value = 2;
|
string value = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
message StringxGet {
|
message GetRequest {
|
||||||
BaseKey key = 1;
|
BaseKey key = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
message StringxComm {
|
message AddRequest {
|
||||||
oneof string_x_comm {
|
BaseKey key = 1;
|
||||||
StringXSet get = 1;
|
int64 value = 2;
|
||||||
StringxGet set = 2;
|
}
|
||||||
}
|
|
||||||
|
message ReduceRequest {
|
||||||
|
BaseKey key = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message SetbitRequest {
|
||||||
|
BaseKey key = 1;
|
||||||
|
}
|
||||||
|
message GetbitRequest {
|
||||||
|
BaseKey key = 1;
|
||||||
}
|
}
|
|
@ -0,0 +1,76 @@
|
||||||
|
import os
|
||||||
|
from typing import Dict, List
|
||||||
|
from jinja2 import Template
|
||||||
|
import yaml
|
||||||
|
|
||||||
|
sysPath = os.getcwd()
|
||||||
|
tempPath = f"{sysPath}/pkg/structure/generate"
|
||||||
|
structurePath = f"{sysPath}/pkg/structure"
|
||||||
|
protobufPath = f"{sysPath}/protobuf"
|
||||||
|
|
||||||
|
def to_camel(val: str) -> str:
|
||||||
|
return "".join([k.capitalize() for k in val.split('_')])
|
||||||
|
|
||||||
|
def load_conf():
|
||||||
|
conf_path = f"{tempPath}/tem.yaml"
|
||||||
|
with open(conf_path, 'r', encoding='utf-8') as f:
|
||||||
|
cfg = f.read()
|
||||||
|
|
||||||
|
cfg = yaml.load(cfg)
|
||||||
|
|
||||||
|
cfg_camel = {}
|
||||||
|
|
||||||
|
for key, val in cfg.items():
|
||||||
|
key = to_camel(key).lower()
|
||||||
|
cfg_camel[key] = [to_camel(v) for v in val]
|
||||||
|
|
||||||
|
# print(cfg_camel)
|
||||||
|
|
||||||
|
return cfg, cfg_camel
|
||||||
|
|
||||||
|
|
||||||
|
# 生成文件,并写入
|
||||||
|
def mkdir(cfg_camel):
|
||||||
|
path = "protobuf"
|
||||||
|
path = path.strip()
|
||||||
|
# 判断路径是否存在
|
||||||
|
isExists = os.path.exists(path)
|
||||||
|
# 判断结果
|
||||||
|
if not isExists:
|
||||||
|
os.makedirs(path)
|
||||||
|
print(path + ' 创建成功')
|
||||||
|
else: # 如果目录存在则不创建,并提示目录已存在
|
||||||
|
# print(path + ' 目录已存在')
|
||||||
|
for key,value in cfg_camel.items():
|
||||||
|
# print(key)
|
||||||
|
proto_path = path + '/' + key + '.proto'
|
||||||
|
if not os.path.exists(proto_path): # 如果这个文件不存在
|
||||||
|
file = open(proto_path,'w')
|
||||||
|
file.write('syntax = "proto3";\nimport "base.proto";\noption go_package = "pkg/proto";\n')
|
||||||
|
for v in value:
|
||||||
|
file.write('\nmessage ' + v +'Request '+'{\n\tBaseKey key = 1;\n}')
|
||||||
|
file.close()
|
||||||
|
else: # 如果这个文件存在
|
||||||
|
with open(proto_path) as f:
|
||||||
|
line = f.readlines()
|
||||||
|
# print(line)
|
||||||
|
f.close()
|
||||||
|
for v in value:
|
||||||
|
function = v + 'Request'
|
||||||
|
flag = 0
|
||||||
|
for l in line:
|
||||||
|
if function in l:
|
||||||
|
flag=1
|
||||||
|
break
|
||||||
|
if flag == 0:
|
||||||
|
file = open(proto_path,'a')
|
||||||
|
file.write('\nmessage ' + v +'Request '+'{\n\tBaseKey key = 1;\n}')
|
||||||
|
file.close()
|
||||||
|
flag = 0
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
conf, cfg_camel = load_conf()
|
||||||
|
#
|
||||||
|
mkdir(cfg_camel)
|
||||||
|
|
|
@ -0,0 +1,109 @@
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
|
def DealList(li: list):
|
||||||
|
# 对列表进行处理
|
||||||
|
flag = 0
|
||||||
|
InterName = []
|
||||||
|
BlankNum = []
|
||||||
|
SliceNum = []
|
||||||
|
for i in range(len(li)):
|
||||||
|
if flag == 0:
|
||||||
|
SliceNum.append(i)
|
||||||
|
InterName.append(f"{li[i].lower().title()}Interface".replace("_", "").replace(":", ""))
|
||||||
|
flag = 1
|
||||||
|
if li[i] == '':
|
||||||
|
BlankNum.append(i)
|
||||||
|
flag = 0
|
||||||
|
Dict = {}
|
||||||
|
for i in range(len(InterName)-1):
|
||||||
|
Dict[InterName[i]] = li[SliceNum[i]+1:BlankNum[i]]
|
||||||
|
Dict[InterName[-1]] = li[BlankNum[-1]+2:]
|
||||||
|
return Dict
|
||||||
|
|
||||||
|
|
||||||
|
def SetInterface():
|
||||||
|
# 对读取到的yaml进行处理
|
||||||
|
Temp = []
|
||||||
|
path = os.getcwd()
|
||||||
|
WirtePath = f"{path}/pkg/structure/interface.go"
|
||||||
|
ReadPath = f"{path}/pkg/structure/generate/tem.yaml"
|
||||||
|
with open(ReadPath, "r") as f:
|
||||||
|
title = f.read()
|
||||||
|
title = title.split("\n")[2:]
|
||||||
|
for i in title:
|
||||||
|
if ' - ' not in i:
|
||||||
|
Temp.append(i)
|
||||||
|
if ' - ' in i:
|
||||||
|
i = i.split("-")[1]
|
||||||
|
Temp.append(i)
|
||||||
|
|
||||||
|
# 对列表进行处理,便于自动补全
|
||||||
|
dic = DealList(Temp)
|
||||||
|
|
||||||
|
# 通过传入的列表对interface.go进行自动补全
|
||||||
|
Temp = []
|
||||||
|
AppendList = []
|
||||||
|
with open(WirtePath, "r") as f:
|
||||||
|
context = f.read()
|
||||||
|
context = context.split("\n")
|
||||||
|
flag = 0
|
||||||
|
for i in context:
|
||||||
|
if "interface" in i:
|
||||||
|
flag = 1 # 开锁
|
||||||
|
if "}" in i:
|
||||||
|
Temp.append(i)
|
||||||
|
AppendList.append(Temp)
|
||||||
|
Temp = []
|
||||||
|
flag = 0 # 上锁
|
||||||
|
if flag == 1:
|
||||||
|
Temp.append(i)
|
||||||
|
|
||||||
|
# 拆分成功, 开始匹配
|
||||||
|
Del = []
|
||||||
|
res = context[0:20]
|
||||||
|
for i in AppendList[2:]:
|
||||||
|
x = i[0:2]
|
||||||
|
for key, values in dic.items():
|
||||||
|
if key in i[0]:
|
||||||
|
Del.append(key)
|
||||||
|
for val in values:
|
||||||
|
x.append(f'\t{val.title().lstrip()}(*pr'
|
||||||
|
f'oto.{val.title().lstrip()}Request) ([]string, error)'.replace("_", ""))
|
||||||
|
x.append("\n}\n\n")
|
||||||
|
for j in x:
|
||||||
|
res.append(j)
|
||||||
|
for i in Del:
|
||||||
|
dic.pop(i)
|
||||||
|
# 添加新增的
|
||||||
|
for key, values in dic.items():
|
||||||
|
w = []
|
||||||
|
w.append(f"type {key} interface" + "{")
|
||||||
|
w.append('\tKeyBaseInterface')
|
||||||
|
for val in values:
|
||||||
|
w.append(f'\t{val.title().lstrip()}(*pr'
|
||||||
|
f'oto.{val.title().lstrip()}Request) ([]string, error)'.replace("_", ""))
|
||||||
|
w.append("\n}\n\n")
|
||||||
|
for j in w:
|
||||||
|
res.append(j)
|
||||||
|
f = open(WirtePath, 'w')
|
||||||
|
judge = ""
|
||||||
|
for i in res:
|
||||||
|
if judge == i:
|
||||||
|
continue
|
||||||
|
judge = i
|
||||||
|
if "package" in i:
|
||||||
|
i = f"{i}\n"
|
||||||
|
if "import" in i:
|
||||||
|
i = f"{i}\n"
|
||||||
|
if i == '':
|
||||||
|
i = '\n'
|
||||||
|
if i == '}' or i == '\n{\n':
|
||||||
|
i = '\n}\n'
|
||||||
|
i = i.replace('\t', '\n\t')
|
||||||
|
f.write(i)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
SetInterface()
|
|
@ -1,72 +1,84 @@
|
||||||
import os
|
import os
|
||||||
|
from typing import Dict, List
|
||||||
from jinja2 import Template
|
from jinja2 import Template
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
sysPath = os.getcwd()
|
sysPath = os.getcwd()
|
||||||
|
tempPath = f"{sysPath}/pkg/structure/generate"
|
||||||
tem_text = '''// Code generated by gen-struct. DO NOT EDIT.
|
structurePath = f"{sysPath}/pkg/structure"
|
||||||
// make gen-struct generated
|
protobufPath = f"{sysPath}/protobuf"
|
||||||
|
|
||||||
package generate
|
|
||||||
|
|
||||||
const (
|
|
||||||
DEFAULT_KEY = iota
|
|
||||||
{% for key in keys %}
|
|
||||||
{{key}}
|
|
||||||
{% endfor %}
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
DEFAULT_COMM = iota
|
|
||||||
{% for key in sets %}
|
|
||||||
{{key}}
|
|
||||||
{% endfor %}
|
|
||||||
)
|
|
||||||
|
|
||||||
var CommKey = map[string]int {
|
|
||||||
{% for kmp in key_maps %}
|
|
||||||
{% for comm in kmp.val %}
|
|
||||||
"{{comm}}": {{kmp.key}},
|
|
||||||
{% endfor %}
|
|
||||||
{% endfor %}
|
|
||||||
}
|
|
||||||
'''
|
|
||||||
|
|
||||||
|
|
||||||
class KeyMap(object):
|
class KeyMap(object):
|
||||||
def __init__(self, key, val) -> None:
|
def __init__(self, key: str, val) -> None:
|
||||||
self.key = key
|
self.key = key
|
||||||
self.val = val
|
self.val = val
|
||||||
|
self.upper = [v.upper() for v in val]
|
||||||
|
|
||||||
|
|
||||||
|
def to_camel(val: str) -> str:
|
||||||
|
return "".join([k.capitalize() for k in val.split('_')])
|
||||||
|
|
||||||
|
|
||||||
|
def load_template(name: str) -> str:
|
||||||
|
with open(f"{tempPath}/{name}", "r", encoding="utf-8") as fp:
|
||||||
|
return fp.read()
|
||||||
|
|
||||||
|
|
||||||
def load_conf():
|
def load_conf():
|
||||||
conf_path = f"{sysPath}/structure/generate/tem.yaml"
|
conf_path = f"{tempPath}/tem.yaml"
|
||||||
with open(conf_path, 'r', encoding='utf-8') as f:
|
with open(conf_path, 'r', encoding='utf-8') as f:
|
||||||
cfg = f.read()
|
cfg = f.read()
|
||||||
|
|
||||||
cfg = yaml.load(cfg)
|
cfg = yaml.load(cfg)
|
||||||
|
|
||||||
return cfg
|
cfg_camel = {}
|
||||||
|
|
||||||
|
for key, val in cfg.items():
|
||||||
|
cfg_camel[key] = [to_camel(v) for v in val]
|
||||||
|
|
||||||
|
print(cfg_camel)
|
||||||
|
|
||||||
|
return cfg, cfg_camel
|
||||||
|
|
||||||
|
|
||||||
def set_structure_template(conf: dict):
|
# 生成常量
|
||||||
|
def set_structure_const_template(conf: dict):
|
||||||
|
tem_text = load_template("const.template")
|
||||||
keys = conf.keys()
|
keys = conf.keys()
|
||||||
key_map = []
|
key_map = []
|
||||||
val_set = []
|
val_set = []
|
||||||
for k, v in conf.items():
|
for k, v in conf.items():
|
||||||
key_map.append(KeyMap(key=k, val=v))
|
key_map.append(KeyMap(key=k, val=v))
|
||||||
|
|
||||||
for val in v:
|
for val in v:
|
||||||
val_set.append(val.upper() + "_COMM")
|
val_set.append(val.upper())
|
||||||
|
|
||||||
template = Template(tem_text)
|
template = Template(tem_text)
|
||||||
text = template.render(keys=keys, key_maps=key_map, sets=val_set)
|
text = template.render(keys=keys, key_maps=key_map, sets=val_set)
|
||||||
|
text.replace("\n\n", "\n")
|
||||||
temp_path = f"{sysPath}/structure/generate/structure.gen.go"
|
|
||||||
|
temp_path = f"{tempPath}/structure.gen.go"
|
||||||
with open(temp_path, 'w', encoding='utf-8') as f:
|
with open(temp_path, 'w', encoding='utf-8') as f:
|
||||||
f.write(text)
|
f.write(text)
|
||||||
|
|
||||||
|
# 生成接口
|
||||||
|
|
||||||
|
|
||||||
|
def set_structure_interface(conf):
|
||||||
|
print(conf)
|
||||||
|
|
||||||
|
# class KeyInterFace
|
||||||
|
|
||||||
|
with open(f"{structurePath}/interface.go") as fp:
|
||||||
|
interfaceText = fp.read()
|
||||||
|
|
||||||
|
for key, item in conf.items():
|
||||||
|
interfaceKey = "".join([k.capitalize() for k in key.split('_')])
|
||||||
|
interfaceTitle = "type "
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
conf = load_conf()
|
conf, cfg_camel = load_conf()
|
||||||
set_structure_template(conf)
|
set_structure_const_template(conf)
|
||||||
|
set_structure_interface(conf)
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue