From 02b3f5cdccac371b1d0489c9e32c79217946df43 Mon Sep 17 00:00:00 2001 From: Azanul Date: Tue, 25 Jul 2023 15:47:54 +0530 Subject: [PATCH] protocol update Signed-off-by: Azanul --- pkg/pressure/pb/pressure.pb.go | 112 ++++++++++++++++++--------------- pkg/pressure/pb/pressure.proto | 3 +- 2 files changed, 63 insertions(+), 52 deletions(-) diff --git a/pkg/pressure/pb/pressure.pb.go b/pkg/pressure/pb/pressure.pb.go index 330cd44..a0df6b1 100644 --- a/pkg/pressure/pb/pressure.pb.go +++ b/pkg/pressure/pb/pressure.pb.go @@ -2,7 +2,7 @@ // versions: // protoc-gen-go v1.31.0 // protoc v4.23.4 -// source: pkg/pressure/pb/something.proto +// source: pkg/pressure/pb/pressure.proto package pb @@ -25,15 +25,16 @@ type Chunk struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - NParts *int32 `protobuf:"varint,1,opt,name=n_parts,json=nParts,proto3,oneof" json:"n_parts,omitempty"` // No. of chucks in the file this chunk belongs to - Index int32 `protobuf:"varint,2,opt,name=index,proto3" json:"index,omitempty"` // Index of the chunk being sent - Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` + Len *int32 `protobuf:"varint,1,opt,name=len,proto3,oneof" json:"len,omitempty"` // No. of bytes of data in this chunk + Index int32 `protobuf:"varint,2,opt,name=index,proto3" json:"index,omitempty"` // Index of the chunk being sent + Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` + Filename *string `protobuf:"bytes,4,opt,name=filename,proto3,oneof" json:"filename,omitempty"` } func (x *Chunk) Reset() { *x = Chunk{} if protoimpl.UnsafeEnabled { - mi := &file_pkg_pressure_pb_something_proto_msgTypes[0] + mi := &file_pkg_pressure_pb_pressure_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -46,7 +47,7 @@ func (x *Chunk) String() string { func (*Chunk) ProtoMessage() {} func (x *Chunk) ProtoReflect() protoreflect.Message { - mi := &file_pkg_pressure_pb_something_proto_msgTypes[0] + mi := &file_pkg_pressure_pb_pressure_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -59,12 +60,12 @@ func (x *Chunk) ProtoReflect() protoreflect.Message { // Deprecated: Use Chunk.ProtoReflect.Descriptor instead. func (*Chunk) Descriptor() ([]byte, []int) { - return file_pkg_pressure_pb_something_proto_rawDescGZIP(), []int{0} + return file_pkg_pressure_pb_pressure_proto_rawDescGZIP(), []int{0} } -func (x *Chunk) GetNParts() int32 { - if x != nil && x.NParts != nil { - return *x.NParts +func (x *Chunk) GetLen() int32 { + if x != nil && x.Len != nil { + return *x.Len } return 0 } @@ -83,6 +84,13 @@ func (x *Chunk) GetData() []byte { return nil } +func (x *Chunk) GetFilename() string { + if x != nil && x.Filename != nil { + return *x.Filename + } + return "" +} + type ChunkRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -94,7 +102,7 @@ type ChunkRequest struct { func (x *ChunkRequest) Reset() { *x = ChunkRequest{} if protoimpl.UnsafeEnabled { - mi := &file_pkg_pressure_pb_something_proto_msgTypes[1] + mi := &file_pkg_pressure_pb_pressure_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -107,7 +115,7 @@ func (x *ChunkRequest) String() string { func (*ChunkRequest) ProtoMessage() {} func (x *ChunkRequest) ProtoReflect() protoreflect.Message { - mi := &file_pkg_pressure_pb_something_proto_msgTypes[1] + mi := &file_pkg_pressure_pb_pressure_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -120,7 +128,7 @@ func (x *ChunkRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ChunkRequest.ProtoReflect.Descriptor instead. func (*ChunkRequest) Descriptor() ([]byte, []int) { - return file_pkg_pressure_pb_something_proto_rawDescGZIP(), []int{1} + return file_pkg_pressure_pb_pressure_proto_rawDescGZIP(), []int{1} } func (x *ChunkRequest) GetIndex() int32 { @@ -130,42 +138,44 @@ func (x *ChunkRequest) GetIndex() int32 { return 0 } -var File_pkg_pressure_pb_something_proto protoreflect.FileDescriptor +var File_pkg_pressure_pb_pressure_proto protoreflect.FileDescriptor -var file_pkg_pressure_pb_something_proto_rawDesc = []byte{ - 0x0a, 0x1f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x65, 0x73, 0x73, 0x75, 0x72, 0x65, 0x2f, 0x70, - 0x62, 0x2f, 0x73, 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x12, 0x0b, 0x70, 0x72, 0x65, 0x73, 0x73, 0x75, 0x72, 0x65, 0x2e, 0x70, 0x62, 0x22, 0x5b, - 0x0a, 0x05, 0x43, 0x68, 0x75, 0x6e, 0x6b, 0x12, 0x1c, 0x0a, 0x07, 0x6e, 0x5f, 0x70, 0x61, 0x72, - 0x74, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x48, 0x00, 0x52, 0x06, 0x6e, 0x50, 0x61, 0x72, - 0x74, 0x73, 0x88, 0x01, 0x01, 0x12, 0x14, 0x0a, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x12, 0x0a, 0x04, 0x64, - 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x42, - 0x0a, 0x0a, 0x08, 0x5f, 0x6e, 0x5f, 0x70, 0x61, 0x72, 0x74, 0x73, 0x22, 0x24, 0x0a, 0x0c, 0x43, - 0x68, 0x75, 0x6e, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x69, - 0x6e, 0x64, 0x65, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x69, 0x6e, 0x64, 0x65, - 0x78, 0x42, 0x13, 0x5a, 0x11, 0x2e, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x65, 0x73, 0x73, - 0x75, 0x72, 0x65, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +var file_pkg_pressure_pb_pressure_proto_rawDesc = []byte{ + 0x0a, 0x1e, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x65, 0x73, 0x73, 0x75, 0x72, 0x65, 0x2f, 0x70, + 0x62, 0x2f, 0x70, 0x72, 0x65, 0x73, 0x73, 0x75, 0x72, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x12, 0x0b, 0x70, 0x72, 0x65, 0x73, 0x73, 0x75, 0x72, 0x65, 0x2e, 0x70, 0x62, 0x22, 0x7e, 0x0a, + 0x05, 0x43, 0x68, 0x75, 0x6e, 0x6b, 0x12, 0x15, 0x0a, 0x03, 0x6c, 0x65, 0x6e, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x05, 0x48, 0x00, 0x52, 0x03, 0x6c, 0x65, 0x6e, 0x88, 0x01, 0x01, 0x12, 0x14, 0x0a, + 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x69, 0x6e, + 0x64, 0x65, 0x78, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x1f, 0x0a, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x6e, + 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x48, 0x01, 0x52, 0x08, 0x66, 0x69, 0x6c, + 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x88, 0x01, 0x01, 0x42, 0x06, 0x0a, 0x04, 0x5f, 0x6c, 0x65, 0x6e, + 0x42, 0x0b, 0x0a, 0x09, 0x5f, 0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x24, 0x0a, + 0x0c, 0x43, 0x68, 0x75, 0x6e, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, + 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x69, 0x6e, + 0x64, 0x65, 0x78, 0x42, 0x13, 0x5a, 0x11, 0x2e, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x65, + 0x73, 0x73, 0x75, 0x72, 0x65, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( - file_pkg_pressure_pb_something_proto_rawDescOnce sync.Once - file_pkg_pressure_pb_something_proto_rawDescData = file_pkg_pressure_pb_something_proto_rawDesc + file_pkg_pressure_pb_pressure_proto_rawDescOnce sync.Once + file_pkg_pressure_pb_pressure_proto_rawDescData = file_pkg_pressure_pb_pressure_proto_rawDesc ) -func file_pkg_pressure_pb_something_proto_rawDescGZIP() []byte { - file_pkg_pressure_pb_something_proto_rawDescOnce.Do(func() { - file_pkg_pressure_pb_something_proto_rawDescData = protoimpl.X.CompressGZIP(file_pkg_pressure_pb_something_proto_rawDescData) +func file_pkg_pressure_pb_pressure_proto_rawDescGZIP() []byte { + file_pkg_pressure_pb_pressure_proto_rawDescOnce.Do(func() { + file_pkg_pressure_pb_pressure_proto_rawDescData = protoimpl.X.CompressGZIP(file_pkg_pressure_pb_pressure_proto_rawDescData) }) - return file_pkg_pressure_pb_something_proto_rawDescData + return file_pkg_pressure_pb_pressure_proto_rawDescData } -var file_pkg_pressure_pb_something_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_pkg_pressure_pb_something_proto_goTypes = []interface{}{ +var file_pkg_pressure_pb_pressure_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_pkg_pressure_pb_pressure_proto_goTypes = []interface{}{ (*Chunk)(nil), // 0: pressure.pb.Chunk (*ChunkRequest)(nil), // 1: pressure.pb.ChunkRequest } -var file_pkg_pressure_pb_something_proto_depIdxs = []int32{ +var file_pkg_pressure_pb_pressure_proto_depIdxs = []int32{ 0, // [0:0] is the sub-list for method output_type 0, // [0:0] is the sub-list for method input_type 0, // [0:0] is the sub-list for extension type_name @@ -173,13 +183,13 @@ var file_pkg_pressure_pb_something_proto_depIdxs = []int32{ 0, // [0:0] is the sub-list for field type_name } -func init() { file_pkg_pressure_pb_something_proto_init() } -func file_pkg_pressure_pb_something_proto_init() { - if File_pkg_pressure_pb_something_proto != nil { +func init() { file_pkg_pressure_pb_pressure_proto_init() } +func file_pkg_pressure_pb_pressure_proto_init() { + if File_pkg_pressure_pb_pressure_proto != nil { return } if !protoimpl.UnsafeEnabled { - file_pkg_pressure_pb_something_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_pkg_pressure_pb_pressure_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Chunk); i { case 0: return &v.state @@ -191,7 +201,7 @@ func file_pkg_pressure_pb_something_proto_init() { return nil } } - file_pkg_pressure_pb_something_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_pkg_pressure_pb_pressure_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ChunkRequest); i { case 0: return &v.state @@ -204,23 +214,23 @@ func file_pkg_pressure_pb_something_proto_init() { } } } - file_pkg_pressure_pb_something_proto_msgTypes[0].OneofWrappers = []interface{}{} + file_pkg_pressure_pb_pressure_proto_msgTypes[0].OneofWrappers = []interface{}{} type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_pkg_pressure_pb_something_proto_rawDesc, + RawDescriptor: file_pkg_pressure_pb_pressure_proto_rawDesc, NumEnums: 0, NumMessages: 2, NumExtensions: 0, NumServices: 0, }, - GoTypes: file_pkg_pressure_pb_something_proto_goTypes, - DependencyIndexes: file_pkg_pressure_pb_something_proto_depIdxs, - MessageInfos: file_pkg_pressure_pb_something_proto_msgTypes, + GoTypes: file_pkg_pressure_pb_pressure_proto_goTypes, + DependencyIndexes: file_pkg_pressure_pb_pressure_proto_depIdxs, + MessageInfos: file_pkg_pressure_pb_pressure_proto_msgTypes, }.Build() - File_pkg_pressure_pb_something_proto = out.File - file_pkg_pressure_pb_something_proto_rawDesc = nil - file_pkg_pressure_pb_something_proto_goTypes = nil - file_pkg_pressure_pb_something_proto_depIdxs = nil + File_pkg_pressure_pb_pressure_proto = out.File + file_pkg_pressure_pb_pressure_proto_rawDesc = nil + file_pkg_pressure_pb_pressure_proto_goTypes = nil + file_pkg_pressure_pb_pressure_proto_depIdxs = nil } diff --git a/pkg/pressure/pb/pressure.proto b/pkg/pressure/pb/pressure.proto index 30c8e96..fe0f686 100644 --- a/pkg/pressure/pb/pressure.proto +++ b/pkg/pressure/pb/pressure.proto @@ -5,9 +5,10 @@ package pressure.pb; option go_package = "./pkg/pressure/pb"; message Chunk { - optional int32 n_parts = 1; // No. of chucks in the file this chunk belongs to + optional int32 len = 1; // No. of bytes of data in this chunk int32 index = 2; // Index of the chunk being sent bytes data = 3; + optional string filename = 4; } message ChunkRequest {