From 8fdd8c81c10ac41214323d12ada21f98d7cd8174 Mon Sep 17 00:00:00 2001 From: Gaius Date: Thu, 16 Nov 2023 15:40:57 +0800 Subject: [PATCH] feat: remove request stream in SyncPieces (#214) Signed-off-by: Gaius --- Cargo.toml | 2 +- pkg/apis/dfdaemon/v2/dfdaemon.pb.go | 50 ++++++++++---------- pkg/apis/dfdaemon/v2/dfdaemon.proto | 2 +- pkg/apis/dfdaemon/v2/dfdaemon_grpc.pb.go | 35 ++++++-------- pkg/apis/dfdaemon/v2/mocks/dfdaemon_mock.go | 45 ++++-------------- proto/dfdaemon.proto | 2 +- src/descriptor.bin | Bin 76793 -> 76777 bytes src/dfdaemon.v2.rs | 16 +++---- 8 files changed, 58 insertions(+), 94 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ac5b8e0..6215ff8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "dragonfly-api" -version = "2.0.51" +version = "2.0.52" authors = ["Gaius "] edition = "2021" license = "Apache-2.0" diff --git a/pkg/apis/dfdaemon/v2/dfdaemon.pb.go b/pkg/apis/dfdaemon/v2/dfdaemon.pb.go index 825c2d5..08eaa93 100644 --- a/pkg/apis/dfdaemon/v2/dfdaemon.pb.go +++ b/pkg/apis/dfdaemon/v2/dfdaemon.pb.go @@ -693,40 +693,40 @@ var file_pkg_apis_dfdaemon_v2_dfdaemon_proto_rawDesc = []byte{ 0x11, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x54, 0x61, 0x73, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x20, 0x0a, 0x07, 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x06, 0x74, 0x61, - 0x73, 0x6b, 0x49, 0x64, 0x32, 0xd9, 0x03, 0x0a, 0x08, 0x44, 0x66, 0x64, 0x61, 0x65, 0x6d, 0x6f, + 0x73, 0x6b, 0x49, 0x64, 0x32, 0xd7, 0x03, 0x0a, 0x08, 0x44, 0x66, 0x64, 0x61, 0x65, 0x6d, 0x6f, 0x6e, 0x12, 0x5c, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x50, 0x69, 0x65, 0x63, 0x65, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x12, 0x23, 0x2e, 0x64, 0x66, 0x64, 0x61, 0x65, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x32, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x69, 0x65, 0x63, 0x65, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x24, 0x2e, 0x64, 0x66, 0x64, 0x61, 0x65, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x32, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x69, 0x65, 0x63, 0x65, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, - 0x51, 0x0a, 0x0a, 0x53, 0x79, 0x6e, 0x63, 0x50, 0x69, 0x65, 0x63, 0x65, 0x73, 0x12, 0x1e, 0x2e, + 0x4f, 0x0a, 0x0a, 0x53, 0x79, 0x6e, 0x63, 0x50, 0x69, 0x65, 0x63, 0x65, 0x73, 0x12, 0x1e, 0x2e, 0x64, 0x66, 0x64, 0x61, 0x65, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x32, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x50, 0x69, 0x65, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x64, 0x66, 0x64, 0x61, 0x65, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x32, 0x2e, 0x53, 0x79, 0x6e, 0x63, - 0x50, 0x69, 0x65, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x28, 0x01, - 0x30, 0x01, 0x12, 0x55, 0x0a, 0x0c, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x54, 0x61, - 0x73, 0x6b, 0x12, 0x20, 0x2e, 0x64, 0x66, 0x64, 0x61, 0x65, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x32, - 0x2e, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x54, 0x61, 0x73, 0x6b, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x64, 0x66, 0x64, 0x61, 0x65, 0x6d, 0x6f, 0x6e, 0x2e, - 0x76, 0x32, 0x2e, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x54, 0x61, 0x73, 0x6b, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x30, 0x01, 0x12, 0x44, 0x0a, 0x0a, 0x55, 0x70, 0x6c, - 0x6f, 0x61, 0x64, 0x54, 0x61, 0x73, 0x6b, 0x12, 0x1e, 0x2e, 0x64, 0x66, 0x64, 0x61, 0x65, 0x6d, - 0x6f, 0x6e, 0x2e, 0x76, 0x32, 0x2e, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x54, 0x61, 0x73, 0x6b, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, - 0x39, 0x0a, 0x08, 0x53, 0x74, 0x61, 0x74, 0x54, 0x61, 0x73, 0x6b, 0x12, 0x1c, 0x2e, 0x64, 0x66, - 0x64, 0x61, 0x65, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x32, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x54, 0x61, - 0x73, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0f, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, - 0x6f, 0x6e, 0x2e, 0x76, 0x32, 0x2e, 0x54, 0x61, 0x73, 0x6b, 0x12, 0x44, 0x0a, 0x0a, 0x44, 0x65, - 0x6c, 0x65, 0x74, 0x65, 0x54, 0x61, 0x73, 0x6b, 0x12, 0x1e, 0x2e, 0x64, 0x66, 0x64, 0x61, 0x65, - 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x32, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x54, 0x61, 0x73, - 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, - 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, - 0x42, 0x2d, 0x5a, 0x2b, 0x64, 0x37, 0x79, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, - 0x32, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x61, 0x70, 0x69, 0x73, 0x2f, 0x64, 0x66, 0x64, 0x61, 0x65, - 0x6d, 0x6f, 0x6e, 0x2f, 0x76, 0x32, 0x3b, 0x64, 0x66, 0x64, 0x61, 0x65, 0x6d, 0x6f, 0x6e, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x50, 0x69, 0x65, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x30, 0x01, + 0x12, 0x55, 0x0a, 0x0c, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x54, 0x61, 0x73, 0x6b, + 0x12, 0x20, 0x2e, 0x64, 0x66, 0x64, 0x61, 0x65, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x32, 0x2e, 0x44, + 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x54, 0x61, 0x73, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x64, 0x66, 0x64, 0x61, 0x65, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x32, + 0x2e, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x54, 0x61, 0x73, 0x6b, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x30, 0x01, 0x12, 0x44, 0x0a, 0x0a, 0x55, 0x70, 0x6c, 0x6f, 0x61, + 0x64, 0x54, 0x61, 0x73, 0x6b, 0x12, 0x1e, 0x2e, 0x64, 0x66, 0x64, 0x61, 0x65, 0x6d, 0x6f, 0x6e, + 0x2e, 0x76, 0x32, 0x2e, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x54, 0x61, 0x73, 0x6b, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x39, 0x0a, + 0x08, 0x53, 0x74, 0x61, 0x74, 0x54, 0x61, 0x73, 0x6b, 0x12, 0x1c, 0x2e, 0x64, 0x66, 0x64, 0x61, + 0x65, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x32, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x54, 0x61, 0x73, 0x6b, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0f, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, + 0x2e, 0x76, 0x32, 0x2e, 0x54, 0x61, 0x73, 0x6b, 0x12, 0x44, 0x0a, 0x0a, 0x44, 0x65, 0x6c, 0x65, + 0x74, 0x65, 0x54, 0x61, 0x73, 0x6b, 0x12, 0x1e, 0x2e, 0x64, 0x66, 0x64, 0x61, 0x65, 0x6d, 0x6f, + 0x6e, 0x2e, 0x76, 0x32, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x54, 0x61, 0x73, 0x6b, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x42, 0x2d, + 0x5a, 0x2b, 0x64, 0x37, 0x79, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x32, 0x2f, + 0x70, 0x6b, 0x67, 0x2f, 0x61, 0x70, 0x69, 0x73, 0x2f, 0x64, 0x66, 0x64, 0x61, 0x65, 0x6d, 0x6f, + 0x6e, 0x2f, 0x76, 0x32, 0x3b, 0x64, 0x66, 0x64, 0x61, 0x65, 0x6d, 0x6f, 0x6e, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/pkg/apis/dfdaemon/v2/dfdaemon.proto b/pkg/apis/dfdaemon/v2/dfdaemon.proto index 53b1b2f..0b0d2c3 100644 --- a/pkg/apis/dfdaemon/v2/dfdaemon.proto +++ b/pkg/apis/dfdaemon/v2/dfdaemon.proto @@ -105,7 +105,7 @@ service Dfdaemon { rpc GetPieceNumbers(GetPieceNumbersRequest) returns(GetPieceNumbersResponse); // SyncPieces syncs pieces from the other peer. - rpc SyncPieces(stream SyncPiecesRequest)returns(stream SyncPiecesResponse); + rpc SyncPieces(SyncPiecesRequest)returns(stream SyncPiecesResponse); // DownloadTask downloads task back-to-source. rpc DownloadTask(DownloadTaskRequest) returns(stream DownloadTaskResponse); diff --git a/pkg/apis/dfdaemon/v2/dfdaemon_grpc.pb.go b/pkg/apis/dfdaemon/v2/dfdaemon_grpc.pb.go index 4f8b655..716b218 100644 --- a/pkg/apis/dfdaemon/v2/dfdaemon_grpc.pb.go +++ b/pkg/apis/dfdaemon/v2/dfdaemon_grpc.pb.go @@ -27,7 +27,7 @@ type DfdaemonClient interface { // GetPieceNumbers gets piece numbers from the other peer. GetPieceNumbers(ctx context.Context, in *GetPieceNumbersRequest, opts ...grpc.CallOption) (*GetPieceNumbersResponse, error) // SyncPieces syncs pieces from the other peer. - SyncPieces(ctx context.Context, opts ...grpc.CallOption) (Dfdaemon_SyncPiecesClient, error) + SyncPieces(ctx context.Context, in *SyncPiecesRequest, opts ...grpc.CallOption) (Dfdaemon_SyncPiecesClient, error) // DownloadTask downloads task back-to-source. DownloadTask(ctx context.Context, in *DownloadTaskRequest, opts ...grpc.CallOption) (Dfdaemon_DownloadTaskClient, error) // UploadTask uploads task to p2p network. @@ -55,17 +55,22 @@ func (c *dfdaemonClient) GetPieceNumbers(ctx context.Context, in *GetPieceNumber return out, nil } -func (c *dfdaemonClient) SyncPieces(ctx context.Context, opts ...grpc.CallOption) (Dfdaemon_SyncPiecesClient, error) { +func (c *dfdaemonClient) SyncPieces(ctx context.Context, in *SyncPiecesRequest, opts ...grpc.CallOption) (Dfdaemon_SyncPiecesClient, error) { stream, err := c.cc.NewStream(ctx, &Dfdaemon_ServiceDesc.Streams[0], "/dfdaemon.v2.Dfdaemon/SyncPieces", opts...) if err != nil { return nil, err } x := &dfdaemonSyncPiecesClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } return x, nil } type Dfdaemon_SyncPiecesClient interface { - Send(*SyncPiecesRequest) error Recv() (*SyncPiecesResponse, error) grpc.ClientStream } @@ -74,10 +79,6 @@ type dfdaemonSyncPiecesClient struct { grpc.ClientStream } -func (x *dfdaemonSyncPiecesClient) Send(m *SyncPiecesRequest) error { - return x.ClientStream.SendMsg(m) -} - func (x *dfdaemonSyncPiecesClient) Recv() (*SyncPiecesResponse, error) { m := new(SyncPiecesResponse) if err := x.ClientStream.RecvMsg(m); err != nil { @@ -152,7 +153,7 @@ type DfdaemonServer interface { // GetPieceNumbers gets piece numbers from the other peer. GetPieceNumbers(context.Context, *GetPieceNumbersRequest) (*GetPieceNumbersResponse, error) // SyncPieces syncs pieces from the other peer. - SyncPieces(Dfdaemon_SyncPiecesServer) error + SyncPieces(*SyncPiecesRequest, Dfdaemon_SyncPiecesServer) error // DownloadTask downloads task back-to-source. DownloadTask(*DownloadTaskRequest, Dfdaemon_DownloadTaskServer) error // UploadTask uploads task to p2p network. @@ -170,7 +171,7 @@ type UnimplementedDfdaemonServer struct { func (UnimplementedDfdaemonServer) GetPieceNumbers(context.Context, *GetPieceNumbersRequest) (*GetPieceNumbersResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetPieceNumbers not implemented") } -func (UnimplementedDfdaemonServer) SyncPieces(Dfdaemon_SyncPiecesServer) error { +func (UnimplementedDfdaemonServer) SyncPieces(*SyncPiecesRequest, Dfdaemon_SyncPiecesServer) error { return status.Errorf(codes.Unimplemented, "method SyncPieces not implemented") } func (UnimplementedDfdaemonServer) DownloadTask(*DownloadTaskRequest, Dfdaemon_DownloadTaskServer) error { @@ -216,12 +217,15 @@ func _Dfdaemon_GetPieceNumbers_Handler(srv interface{}, ctx context.Context, dec } func _Dfdaemon_SyncPieces_Handler(srv interface{}, stream grpc.ServerStream) error { - return srv.(DfdaemonServer).SyncPieces(&dfdaemonSyncPiecesServer{stream}) + m := new(SyncPiecesRequest) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(DfdaemonServer).SyncPieces(m, &dfdaemonSyncPiecesServer{stream}) } type Dfdaemon_SyncPiecesServer interface { Send(*SyncPiecesResponse) error - Recv() (*SyncPiecesRequest, error) grpc.ServerStream } @@ -233,14 +237,6 @@ func (x *dfdaemonSyncPiecesServer) Send(m *SyncPiecesResponse) error { return x.ServerStream.SendMsg(m) } -func (x *dfdaemonSyncPiecesServer) Recv() (*SyncPiecesRequest, error) { - m := new(SyncPiecesRequest) - if err := x.ServerStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - func _Dfdaemon_DownloadTask_Handler(srv interface{}, stream grpc.ServerStream) error { m := new(DownloadTaskRequest) if err := stream.RecvMsg(m); err != nil { @@ -345,7 +341,6 @@ var Dfdaemon_ServiceDesc = grpc.ServiceDesc{ StreamName: "SyncPieces", Handler: _Dfdaemon_SyncPieces_Handler, ServerStreams: true, - ClientStreams: true, }, { StreamName: "DownloadTask", diff --git a/pkg/apis/dfdaemon/v2/mocks/dfdaemon_mock.go b/pkg/apis/dfdaemon/v2/mocks/dfdaemon_mock.go index 5254df6..d90a916 100644 --- a/pkg/apis/dfdaemon/v2/mocks/dfdaemon_mock.go +++ b/pkg/apis/dfdaemon/v2/mocks/dfdaemon_mock.go @@ -124,9 +124,9 @@ func (mr *MockDfdaemonClientMockRecorder) StatTask(ctx, in any, opts ...any) *go } // SyncPieces mocks base method. -func (m *MockDfdaemonClient) SyncPieces(ctx context.Context, opts ...grpc.CallOption) (dfdaemon.Dfdaemon_SyncPiecesClient, error) { +func (m *MockDfdaemonClient) SyncPieces(ctx context.Context, in *dfdaemon.SyncPiecesRequest, opts ...grpc.CallOption) (dfdaemon.Dfdaemon_SyncPiecesClient, error) { m.ctrl.T.Helper() - varargs := []any{ctx} + varargs := []any{ctx, in} for _, a := range opts { varargs = append(varargs, a) } @@ -137,9 +137,9 @@ func (m *MockDfdaemonClient) SyncPieces(ctx context.Context, opts ...grpc.CallOp } // SyncPieces indicates an expected call of SyncPieces. -func (mr *MockDfdaemonClientMockRecorder) SyncPieces(ctx any, opts ...any) *gomock.Call { +func (mr *MockDfdaemonClientMockRecorder) SyncPieces(ctx, in any, opts ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]any{ctx}, opts...) + varargs := append([]any{ctx, in}, opts...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SyncPieces", reflect.TypeOf((*MockDfdaemonClient)(nil).SyncPieces), varargs...) } @@ -258,20 +258,6 @@ func (mr *MockDfdaemon_SyncPiecesClientMockRecorder) RecvMsg(m any) *gomock.Call return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RecvMsg", reflect.TypeOf((*MockDfdaemon_SyncPiecesClient)(nil).RecvMsg), m) } -// Send mocks base method. -func (m *MockDfdaemon_SyncPiecesClient) Send(arg0 *dfdaemon.SyncPiecesRequest) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Send", arg0) - ret0, _ := ret[0].(error) - return ret0 -} - -// Send indicates an expected call of Send. -func (mr *MockDfdaemon_SyncPiecesClientMockRecorder) Send(arg0 any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Send", reflect.TypeOf((*MockDfdaemon_SyncPiecesClient)(nil).Send), arg0) -} - // SendMsg mocks base method. func (m_2 *MockDfdaemon_SyncPiecesClient) SendMsg(m any) error { m_2.ctrl.T.Helper() @@ -506,17 +492,17 @@ func (mr *MockDfdaemonServerMockRecorder) StatTask(arg0, arg1 any) *gomock.Call } // SyncPieces mocks base method. -func (m *MockDfdaemonServer) SyncPieces(arg0 dfdaemon.Dfdaemon_SyncPiecesServer) error { +func (m *MockDfdaemonServer) SyncPieces(arg0 *dfdaemon.SyncPiecesRequest, arg1 dfdaemon.Dfdaemon_SyncPiecesServer) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SyncPieces", arg0) + ret := m.ctrl.Call(m, "SyncPieces", arg0, arg1) ret0, _ := ret[0].(error) return ret0 } // SyncPieces indicates an expected call of SyncPieces. -func (mr *MockDfdaemonServerMockRecorder) SyncPieces(arg0 any) *gomock.Call { +func (mr *MockDfdaemonServerMockRecorder) SyncPieces(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SyncPieces", reflect.TypeOf((*MockDfdaemonServer)(nil).SyncPieces), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SyncPieces", reflect.TypeOf((*MockDfdaemonServer)(nil).SyncPieces), arg0, arg1) } // UploadTask mocks base method. @@ -606,21 +592,6 @@ func (mr *MockDfdaemon_SyncPiecesServerMockRecorder) Context() *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Context", reflect.TypeOf((*MockDfdaemon_SyncPiecesServer)(nil).Context)) } -// Recv mocks base method. -func (m *MockDfdaemon_SyncPiecesServer) Recv() (*dfdaemon.SyncPiecesRequest, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Recv") - ret0, _ := ret[0].(*dfdaemon.SyncPiecesRequest) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// Recv indicates an expected call of Recv. -func (mr *MockDfdaemon_SyncPiecesServerMockRecorder) Recv() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Recv", reflect.TypeOf((*MockDfdaemon_SyncPiecesServer)(nil).Recv)) -} - // RecvMsg mocks base method. func (m_2 *MockDfdaemon_SyncPiecesServer) RecvMsg(m any) error { m_2.ctrl.T.Helper() diff --git a/proto/dfdaemon.proto b/proto/dfdaemon.proto index 782c1c4..6af1485 100644 --- a/proto/dfdaemon.proto +++ b/proto/dfdaemon.proto @@ -98,7 +98,7 @@ service Dfdaemon{ rpc GetPieceNumbers(GetPieceNumbersRequest) returns(GetPieceNumbersResponse); // SyncPieces syncs pieces from the other peer. - rpc SyncPieces(stream SyncPiecesRequest)returns(stream SyncPiecesResponse); + rpc SyncPieces(SyncPiecesRequest)returns(stream SyncPiecesResponse); // DownloadTask downloads task back-to-source. rpc DownloadTask(DownloadTaskRequest) returns(stream DownloadTaskResponse); diff --git a/src/descriptor.bin b/src/descriptor.bin index 98284c85c24d2b09c123e803f2fccf82059b3508..661e0f4ab709399f2a0591066bff74768264c61b 100644 GIT binary patch delta 86 zcmex)o#o|qmJQe185eK9-rma0cztqgcNU}n<=MCPp?OPumd2V+Qh!TsG&;=$;G!w^kb$ delta 116 zcmaEPo#p3smJQe188>gf-rma0cyn@WcNSyd, + request: impl tonic::IntoRequest, ) -> std::result::Result< tonic::Response>, tonic::Status, @@ -251,10 +251,10 @@ pub mod dfdaemon_client { let path = http::uri::PathAndQuery::from_static( "/dfdaemon.v2.Dfdaemon/SyncPieces", ); - let mut req = request.into_streaming_request(); + let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("dfdaemon.v2.Dfdaemon", "SyncPieces")); - self.inner.streaming(req, path, codec).await + self.inner.server_streaming(req, path, codec).await } /// DownloadTask downloads task back-to-source. pub async fn download_task( @@ -380,7 +380,7 @@ pub mod dfdaemon_server { /// SyncPieces syncs pieces from the other peer. async fn sync_pieces( &self, - request: tonic::Request>, + request: tonic::Request, ) -> std::result::Result, tonic::Status>; /// Server streaming response type for the DownloadTask method. type DownloadTaskStream: futures_core::Stream< @@ -546,7 +546,7 @@ pub mod dfdaemon_server { struct SyncPiecesSvc(pub Arc); impl< T: Dfdaemon, - > tonic::server::StreamingService + > tonic::server::ServerStreamingService for SyncPiecesSvc { type Response = super::SyncPiecesResponse; type ResponseStream = T::SyncPiecesStream; @@ -556,9 +556,7 @@ pub mod dfdaemon_server { >; fn call( &mut self, - request: tonic::Request< - tonic::Streaming, - >, + request: tonic::Request, ) -> Self::Future { let inner = Arc::clone(&self.0); let fut = async move { (*inner).sync_pieces(request).await }; @@ -583,7 +581,7 @@ pub mod dfdaemon_server { max_decoding_message_size, max_encoding_message_size, ); - let res = grpc.streaming(method, req).await; + let res = grpc.server_streaming(method, req).await; Ok(res) }; Box::pin(fut)