From 10d721b970db7cf702155fd74c12d6ca90bc8e36 Mon Sep 17 00:00:00 2001 From: Sergey Cherepanov Date: Tue, 31 Jan 2023 14:24:39 +0300 Subject: [PATCH] update fileproto: unary method instead stream for blocksGet --- commonfile/fileproto/file.pb.go | 145 +++++++------------------ commonfile/fileproto/file_drpc.pb.go | 67 +++--------- commonfile/fileproto/protos/file.proto | 16 +-- 3 files changed, 59 insertions(+), 169 deletions(-) diff --git a/commonfile/fileproto/file.pb.go b/commonfile/fileproto/file.pb.go index 9a01c05a..5f295f0b 100644 --- a/commonfile/fileproto/file.pb.go +++ b/commonfile/fileproto/file.pb.go @@ -78,34 +78,6 @@ func (AvailabilityStatus) EnumDescriptor() ([]byte, []int) { return fileDescriptor_fd665a7e11c833d5, []int{1} } -type CIDError int32 - -const ( - CIDError_CIDErrorOk CIDError = 0 - CIDError_CIDErrorNotFound CIDError = 1 - CIDError_CIDErrorUnexpected CIDError = 2 -) - -var CIDError_name = map[int32]string{ - 0: "CIDErrorOk", - 1: "CIDErrorNotFound", - 2: "CIDErrorUnexpected", -} - -var CIDError_value = map[string]int32{ - "CIDErrorOk": 0, - "CIDErrorNotFound": 1, - "CIDErrorUnexpected": 2, -} - -func (x CIDError) String() string { - return proto.EnumName(CIDError_name, int32(x)) -} - -func (CIDError) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_fd665a7e11c833d5, []int{2} -} - type BlockGetRequest struct { SpaceId string `protobuf:"bytes,1,opt,name=spaceId,proto3" json:"spaceId,omitempty"` Cid []byte `protobuf:"bytes,2,opt,name=cid,proto3" json:"cid,omitempty"` @@ -159,9 +131,8 @@ func (m *BlockGetRequest) GetCid() []byte { } type BlockGetResponse struct { - Cid []byte `protobuf:"bytes,1,opt,name=cid,proto3" json:"cid,omitempty"` - Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` - Code CIDError `protobuf:"varint,3,opt,name=code,proto3,enum=filesync.CIDError" json:"code,omitempty"` + Cid []byte `protobuf:"bytes,1,opt,name=cid,proto3" json:"cid,omitempty"` + Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` } func (m *BlockGetResponse) Reset() { *m = BlockGetResponse{} } @@ -211,13 +182,6 @@ func (m *BlockGetResponse) GetData() []byte { return nil } -func (m *BlockGetResponse) GetCode() CIDError { - if m != nil { - return m.Code - } - return CIDError_CIDErrorOk -} - type BlockPushRequest struct { SpaceId string `protobuf:"bytes,1,opt,name=spaceId,proto3" json:"spaceId,omitempty"` Cid []byte `protobuf:"bytes,2,opt,name=cid,proto3" json:"cid,omitempty"` @@ -721,7 +685,6 @@ func (m *CheckResponse) GetSpaceIds() []string { func init() { proto.RegisterEnum("filesync.ErrCodes", ErrCodes_name, ErrCodes_value) proto.RegisterEnum("filesync.AvailabilityStatus", AvailabilityStatus_name, AvailabilityStatus_value) - proto.RegisterEnum("filesync.CIDError", CIDError_name, CIDError_value) proto.RegisterType((*BlockGetRequest)(nil), "filesync.BlockGetRequest") proto.RegisterType((*BlockGetResponse)(nil), "filesync.BlockGetResponse") proto.RegisterType((*BlockPushRequest)(nil), "filesync.BlockPushRequest") @@ -742,46 +705,43 @@ func init() { } var fileDescriptor_fd665a7e11c833d5 = []byte{ - // 623 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x54, 0xcf, 0x4e, 0xdb, 0x4e, - 0x10, 0xce, 0x26, 0xf9, 0xf1, 0x4b, 0x26, 0x10, 0xcc, 0x10, 0xd1, 0xd4, 0x50, 0x2b, 0xf2, 0x01, - 0x45, 0x54, 0x0a, 0x55, 0xda, 0x43, 0x2f, 0x1c, 0x48, 0x02, 0x34, 0xad, 0x0a, 0x95, 0x51, 0x2f, - 0xed, 0xa5, 0x89, 0xbd, 0x08, 0x0b, 0xe3, 0x4d, 0xbd, 0x9b, 0x0a, 0xde, 0xa2, 0xcf, 0xd2, 0xa7, - 0xe0, 0xc8, 0xb1,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x00, 0x00, 0x00, 0xff, 0xff, 0x15, 0xd1, 0x3a, 0x81, 0xee, 0x05, 0x00, 0x00, + // 567 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x94, 0xcd, 0x6e, 0xda, 0x40, + 0x10, 0xc7, 0x59, 0xa0, 0x14, 0x86, 0x8f, 0x38, 0x1b, 0x94, 0x52, 0x87, 0x5a, 0xc8, 0x87, 0x0a, + 0xa5, 0x12, 0x91, 0x68, 0x0f, 0xb9, 0xe4, 0x10, 0x03, 0x41, 0xb4, 0x6a, 0x5a, 0x39, 0xea, 0xa5, + 0x3d, 0x19, 0x7b, 0x51, 0xac, 0x38, 0x5e, 0xea, 0x5d, 0xaa, 0xe4, 0x2d, 0xfa, 0x24, 0x7d, 0x8e, + 0x1c, 0x73, 0xec, 0xb1, 0x82, 0x17, 0xa9, 0xbc, 0x5e, 0xc0, 0x06, 0x47, 0x91, 0xb8, 0x98, 0xd9, + 0xf9, 0xf8, 0xcd, 0xce, 0x7f, 0x77, 0x81, 0xb7, 0x36, 0xbd, 0xbd, 0xa5, 0xfe, 0xc4, 0xf5, 0xc8, + 0x49, 0xf8, 0x99, 0x06, 0x94, 0xd3, 0x13, 0xf1, 0x65, 0xc2, 0xd1, 0x11, 0x36, 0x2e, 0x86, 0x36, + 0xbb, 0xf7, 0x6d, 0xfd, 0x0c, 0xf6, 0x0c, 0x8f, 0xda, 0x37, 0x43, 0xc2, 0x4d, 0xf2, 0x73, 0x46, + 0x18, 0xc7, 0x0d, 0x78, 0xc9, 0xa6, 0x96, 0x4d, 0x46, 0x4e, 0x03, 0xb5, 0x50, 0xbb, 0x64, 0x2e, + 0x97, 0x58, 0x81, 0x9c, 0xed, 0x3a, 0x8d, 0x6c, 0x0b, 0xb5, 0x2b, 0x66, 0x68, 0xea, 0xa7, 0xa0, + 0xac, 0xcb, 0xd9, 0x94, 0xfa, 0x8c, 0x2c,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f, 0xb9, 0x86, 0x7e, 0x2f, 0xb4, 0xcc, 0xe3, 0x42, 0xcb, 0xfc, 0x5d, 0x68, 0x99, + 0xef, 0xf5, 0xb4, 0x7f, 0xd6, 0x71, 0x41, 0xfc, 0xbc, 0xff, 0x1f, 0x00, 0x00, 0xff, 0xff, 0xbc, + 0x48, 0x8b, 0xe1, 0x78, 0x05, 0x00, 0x00, } func (m *BlockGetRequest) Marshal() (dAtA []byte, err error) { @@ -841,11 +801,6 @@ func (m *BlockGetResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.Code != 0 { - i = encodeVarintFile(dAtA, i, uint64(m.Code)) - i-- - dAtA[i] = 0x18 - } if len(m.Data) > 0 { i -= len(m.Data) copy(dAtA[i:], m.Data) @@ -1262,9 +1217,6 @@ func (m *BlockGetResponse) Size() (n int) { if l > 0 { n += 1 + l + sovFile(uint64(l)) } - if m.Code != 0 { - n += 1 + sovFile(uint64(m.Code)) - } return n } @@ -1647,25 +1599,6 @@ func (m *BlockGetResponse) Unmarshal(dAtA []byte) error { m.Data = []byte{} } iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Code", wireType) - } - m.Code = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowFile - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Code |= CIDError(b&0x7F) << shift - if b < 0x80 { - break - } - } default: iNdEx = preIndex skippy, err := skipFile(dAtA[iNdEx:]) diff --git a/commonfile/fileproto/file_drpc.pb.go b/commonfile/fileproto/file_drpc.pb.go index be82842c..87f98ce5 100644 --- a/commonfile/fileproto/file_drpc.pb.go +++ b/commonfile/fileproto/file_drpc.pb.go @@ -40,7 +40,7 @@ func (drpcEncoding_File_commonfile_fileproto_protos_file_proto) JSONUnmarshal(bu type DRPCFileClient interface { DRPCConn() drpc.Conn - BlocksGet(ctx context.Context) (DRPCFile_BlocksGetClient, error) + BlocksGet(ctx context.Context, in *BlockGetRequest) (*BlockGetResponse, error) BlockPush(ctx context.Context, in *BlockPushRequest) (*BlockPushResponse, error) BlocksCheck(ctx context.Context, in *BlocksCheckRequest) (*BlocksCheckResponse, error) BlocksBind(ctx context.Context, in *BlocksBindRequest) (*BlocksBindResponse, error) @@ -58,39 +58,13 @@ func NewDRPCFileClient(cc drpc.Conn) DRPCFileClient { func (c *drpcFileClient) DRPCConn() drpc.Conn { return c.cc } -func (c *drpcFileClient) BlocksGet(ctx context.Context) (DRPCFile_BlocksGetClient, error) { - stream, err := c.cc.NewStream(ctx, "/filesync.File/BlocksGet", drpcEncoding_File_commonfile_fileproto_protos_file_proto{}) +func (c *drpcFileClient) BlocksGet(ctx context.Context, in *BlockGetRequest) (*BlockGetResponse, error) { + out := new(BlockGetResponse) + err := c.cc.Invoke(ctx, "/filesync.File/BlocksGet", drpcEncoding_File_commonfile_fileproto_protos_file_proto{}, in, out) if err != nil { return nil, err } - x := &drpcFile_BlocksGetClient{stream} - return x, nil -} - -type DRPCFile_BlocksGetClient interface { - drpc.Stream - Send(*BlockGetRequest) error - Recv() (*BlockGetResponse, error) -} - -type drpcFile_BlocksGetClient struct { - drpc.Stream -} - -func (x *drpcFile_BlocksGetClient) Send(m *BlockGetRequest) error { - return x.MsgSend(m, drpcEncoding_File_commonfile_fileproto_protos_file_proto{}) -} - -func (x *drpcFile_BlocksGetClient) Recv() (*BlockGetResponse, error) { - m := new(BlockGetResponse) - if err := x.MsgRecv(m, drpcEncoding_File_commonfile_fileproto_protos_file_proto{}); err != nil { - return nil, err - } - return m, nil -} - -func (x *drpcFile_BlocksGetClient) RecvMsg(m *BlockGetResponse) error { - return x.MsgRecv(m, drpcEncoding_File_commonfile_fileproto_protos_file_proto{}) + return out, nil } func (c *drpcFileClient) BlockPush(ctx context.Context, in *BlockPushRequest) (*BlockPushResponse, error) { @@ -139,7 +113,7 @@ func (c *drpcFileClient) Check(ctx context.Context, in *CheckRequest) (*CheckRes } type DRPCFileServer interface { - BlocksGet(DRPCFile_BlocksGetStream) error + BlocksGet(context.Context, *BlockGetRequest) (*BlockGetResponse, error) BlockPush(context.Context, *BlockPushRequest) (*BlockPushResponse, error) BlocksCheck(context.Context, *BlocksCheckRequest) (*BlocksCheckResponse, error) BlocksBind(context.Context, *BlocksBindRequest) (*BlocksBindResponse, error) @@ -149,8 +123,8 @@ type DRPCFileServer interface { type DRPCFileUnimplementedServer struct{} -func (s *DRPCFileUnimplementedServer) BlocksGet(DRPCFile_BlocksGetStream) error { - return drpcerr.WithCode(errors.New("Unimplemented"), drpcerr.Unimplemented) +func (s *DRPCFileUnimplementedServer) BlocksGet(context.Context, *BlockGetRequest) (*BlockGetResponse, error) { + return nil, drpcerr.WithCode(errors.New("Unimplemented"), drpcerr.Unimplemented) } func (s *DRPCFileUnimplementedServer) BlockPush(context.Context, *BlockPushRequest) (*BlockPushResponse, error) { @@ -182,9 +156,10 @@ func (DRPCFileDescription) Method(n int) (string, drpc.Encoding, drpc.Receiver, case 0: return "/filesync.File/BlocksGet", drpcEncoding_File_commonfile_fileproto_protos_file_proto{}, func(srv interface{}, ctx context.Context, in1, in2 interface{}) (drpc.Message, error) { - return nil, srv.(DRPCFileServer). + return srv.(DRPCFileServer). BlocksGet( - &drpcFile_BlocksGetStream{in1.(drpc.Stream)}, + ctx, + in1.(*BlockGetRequest), ) }, DRPCFileServer.BlocksGet, true case 1: @@ -243,28 +218,18 @@ func DRPCRegisterFile(mux drpc.Mux, impl DRPCFileServer) error { type DRPCFile_BlocksGetStream interface { drpc.Stream - Send(*BlockGetResponse) error - Recv() (*BlockGetRequest, error) + SendAndClose(*BlockGetResponse) error } type drpcFile_BlocksGetStream struct { drpc.Stream } -func (x *drpcFile_BlocksGetStream) Send(m *BlockGetResponse) error { - return x.MsgSend(m, drpcEncoding_File_commonfile_fileproto_protos_file_proto{}) -} - -func (x *drpcFile_BlocksGetStream) Recv() (*BlockGetRequest, error) { - m := new(BlockGetRequest) - if err := x.MsgRecv(m, drpcEncoding_File_commonfile_fileproto_protos_file_proto{}); err != nil { - return nil, err +func (x *drpcFile_BlocksGetStream) SendAndClose(m *BlockGetResponse) error { + if err := x.MsgSend(m, drpcEncoding_File_commonfile_fileproto_protos_file_proto{}); err != nil { + return err } - return m, nil -} - -func (x *drpcFile_BlocksGetStream) RecvMsg(m *BlockGetRequest) error { - return x.MsgRecv(m, drpcEncoding_File_commonfile_fileproto_protos_file_proto{}) + return x.CloseSend() } type DRPCFile_BlockPushStream interface { diff --git a/commonfile/fileproto/protos/file.proto b/commonfile/fileproto/protos/file.proto index 5b7369ef..07c778fe 100644 --- a/commonfile/fileproto/protos/file.proto +++ b/commonfile/fileproto/protos/file.proto @@ -11,16 +11,16 @@ enum ErrCodes { service File { // GetBlocks streams ipfs blocks from server to client - rpc BlocksGet(stream BlockGetRequest) returns (stream BlockGetResponse); - // PushBlock pushes one block to server + rpc BlocksGet(BlockGetRequest) returns (BlockGetResponse); + // BlockPush pushes one block to server rpc BlockPush(BlockPushRequest) returns (BlockPushResponse); // BlocksCheck checks is CIDs exists rpc BlocksCheck(BlocksCheckRequest) returns (BlocksCheckResponse); // BlocksBind binds CIDs to space rpc BlocksBind(BlocksBindRequest) returns (BlocksBindResponse); - // DeleteBlock deletes block from space + // BlocksDelete deletes block from space rpc BlocksDelete(BlocksDeleteRequest) returns (BlocksDeleteResponse); - // Ping checks the connection + // Check checks the connection and credentials rpc Check(CheckRequest) returns (CheckResponse); } @@ -32,7 +32,6 @@ message BlockGetRequest { message BlockGetResponse { bytes cid = 1; bytes data = 2; - CIDError code = 3; } message BlockPushRequest { @@ -83,10 +82,3 @@ message CheckRequest {} message CheckResponse { repeated string spaceIds = 1; } - - -enum CIDError { - CIDErrorOk = 0; - CIDErrorNotFound = 1; - CIDErrorUnexpected = 2; -} \ No newline at end of file