chore(project): add comm proto

This commit is contained in:
bandl 2021-08-31 23:30:55 +08:00
parent 6453b2a0ce
commit 8c114bcb9a
2 changed files with 400 additions and 0 deletions

View File

@ -0,0 +1,23 @@
syntax = "proto3";
option go_package = "storage/proto";
message Comm {
string key = 1;
string Operation = 2;
repeated string Option = 3;
}
message CommendRequest {
repeated Comm commends = 1;
}
message CommendResponse {
repeated string result = 1;
}
service CommServer {
rpc Commend (CommendRequest) returns (CommendResponse);
}

377
storage/proto/storage.pb.go Normal file
View File

@ -0,0 +1,377 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.26.0
// protoc v3.17.3
// source: storage.proto
package proto
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type Comm struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
Operation string `protobuf:"bytes,2,opt,name=Operation,proto3" json:"Operation,omitempty"`
Option []string `protobuf:"bytes,3,rep,name=Option,proto3" json:"Option,omitempty"`
}
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 (x *Comm) GetKey() string {
if x != nil {
return x.Key
}
return ""
}
func (x *Comm) GetOperation() string {
if x != nil {
return x.Operation
}
return ""
}
func (x *Comm) GetOption() []string {
if x != nil {
return x.Option
}
return nil
}
type CommendRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Commends []*Comm `protobuf:"bytes,1,rep,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
unknownFields protoimpl.UnknownFields
Result []string `protobuf:"bytes,1,rep,name=result,proto3" json:"result,omitempty"`
}
func (x *CommendResponse) Reset() {
*x = CommendResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_storage_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *CommendResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*CommendResponse) ProtoMessage() {}
func (x *CommendResponse) ProtoReflect() protoreflect.Message {
mi := &file_storage_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use CommendResponse.ProtoReflect.Descriptor instead.
func (*CommendResponse) Descriptor() ([]byte, []int) {
return file_storage_proto_rawDescGZIP(), []int{2}
}
func (x *CommendResponse) GetResult() []string {
if x != nil {
return x.Result
}
return nil
}
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, 0x22,
0x4e, 0x0a, 0x04, 0x43, 0x6f, 0x6d, 0x6d, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01,
0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x1c, 0x0a, 0x09, 0x4f, 0x70, 0x65,
0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x4f, 0x70,
0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x4f, 0x70, 0x74, 0x69, 0x6f,
0x6e, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x4f, 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,
0x03, 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, 0x0f, 0x5a, 0x0d, 0x73,
0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x33,
}
var (
file_storage_proto_rawDescOnce sync.Once
file_storage_proto_rawDescData = file_storage_proto_rawDesc
)
func file_storage_proto_rawDescGZIP() []byte {
file_storage_proto_rawDescOnce.Do(func() {
file_storage_proto_rawDescData = protoimpl.X.CompressGZIP(file_storage_proto_rawDescData)
})
return file_storage_proto_rawDescData
}
var file_storage_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
var file_storage_proto_goTypes = []interface{}{
(*Comm)(nil), // 0: Comm
(*CommendRequest)(nil), // 1: CommendRequest
(*CommendResponse)(nil), // 2: CommendResponse
}
var file_storage_proto_depIdxs = []int32{
0, // 0: CommendRequest.commends:type_name -> Comm
1, // 1: CommServer.Commend:input_type -> CommendRequest
2, // 2: CommServer.Commend:output_type -> CommendResponse
2, // [2:3] is the sub-list for method output_type
1, // [1:2] is the sub-list for method input_type
1, // [1:1] is the sub-list for extension type_name
1, // [1:1] is the sub-list for extension extendee
0, // [0:1] is the sub-list for field type_name
}
func init() { file_storage_proto_init() }
func file_storage_proto_init() {
if File_storage_proto != nil {
return
}
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
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_storage_proto_rawDesc,
NumEnums: 0,
NumMessages: 3,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_storage_proto_goTypes,
DependencyIndexes: file_storage_proto_depIdxs,
MessageInfos: file_storage_proto_msgTypes,
}.Build()
File_storage_proto = out.File
file_storage_proto_rawDesc = nil
file_storage_proto_goTypes = nil
file_storage_proto_depIdxs = nil
}
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ grpc.ClientConnInterface
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion6
// CommServerClient is the client API for CommServer service.
//
// 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)
}
type commServerClient struct {
cc grpc.ClientConnInterface
}
func NewCommServerClient(cc grpc.ClientConnInterface) CommServerClient {
return &commServerClient{cc}
}
func (c *commServerClient) Commend(ctx context.Context, in *CommendRequest, opts ...grpc.CallOption) (*CommendResponse, error) {
out := new(CommendResponse)
err := c.cc.Invoke(ctx, "/CommServer/Commend", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// CommServerServer is the server API for CommServer service.
type CommServerServer interface {
Commend(context.Context, *CommendRequest) (*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 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)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(CommServerServer).Commend(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/CommServer/Commend",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(CommServerServer).Commend(ctx, req.(*CommendRequest))
}
return interceptor(ctx, in, info, handler)
}
var _CommServer_serviceDesc = grpc.ServiceDesc{
ServiceName: "CommServer",
HandlerType: (*CommServerServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Commend",
Handler: _CommServer_Commend_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "storage.proto",
}