feat: remove update_persistent_cache_task api (#451)

Signed-off-by: Gaius <gaius.qi@gmail.com>
This commit is contained in:
Gaius 2025-01-24 17:52:18 +08:00 committed by GitHub
parent 2a23158326
commit 05b74d50e3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 371 additions and 767 deletions

2
Cargo.lock generated
View File

@ -190,7 +190,7 @@ dependencies = [
[[package]]
name = "dragonfly-api"
version = "2.1.15"
version = "2.1.16"
dependencies = [
"prost",
"prost-types",

View File

@ -1,6 +1,6 @@
[package]
name = "dragonfly-api"
version = "2.1.15"
version = "2.1.16"
authors = ["Gaius <gaius.qi@gmail.com>"]
edition = "2021"
license = "Apache-2.0"

File diff suppressed because it is too large Load Diff

View File

@ -1382,124 +1382,6 @@ var _ interface {
ErrorName() string
} = UploadTaskRequestValidationError{}
// Validate checks the field values on UpdatePersistentCacheTaskRequest with
// the rules defined in the proto definition for this message. If any rules
// are violated, the first error encountered is returned, or nil if there are
// no violations.
func (m *UpdatePersistentCacheTaskRequest) Validate() error {
return m.validate(false)
}
// ValidateAll checks the field values on UpdatePersistentCacheTaskRequest with
// the rules defined in the proto definition for this message. If any rules
// are violated, the result is a list of violation errors wrapped in
// UpdatePersistentCacheTaskRequestMultiError, or nil if none found.
func (m *UpdatePersistentCacheTaskRequest) ValidateAll() error {
return m.validate(true)
}
func (m *UpdatePersistentCacheTaskRequest) validate(all bool) error {
if m == nil {
return nil
}
var errors []error
if utf8.RuneCountInString(m.GetTaskId()) < 1 {
err := UpdatePersistentCacheTaskRequestValidationError{
field: "TaskId",
reason: "value length must be at least 1 runes",
}
if !all {
return err
}
errors = append(errors, err)
}
// no validation rules for Persistent
if len(errors) > 0 {
return UpdatePersistentCacheTaskRequestMultiError(errors)
}
return nil
}
// UpdatePersistentCacheTaskRequestMultiError is an error wrapping multiple
// validation errors returned by
// UpdatePersistentCacheTaskRequest.ValidateAll() if the designated
// constraints aren't met.
type UpdatePersistentCacheTaskRequestMultiError []error
// Error returns a concatenation of all the error messages it wraps.
func (m UpdatePersistentCacheTaskRequestMultiError) Error() string {
var msgs []string
for _, err := range m {
msgs = append(msgs, err.Error())
}
return strings.Join(msgs, "; ")
}
// AllErrors returns a list of validation violation errors.
func (m UpdatePersistentCacheTaskRequestMultiError) AllErrors() []error { return m }
// UpdatePersistentCacheTaskRequestValidationError is the validation error
// returned by UpdatePersistentCacheTaskRequest.Validate if the designated
// constraints aren't met.
type UpdatePersistentCacheTaskRequestValidationError struct {
field string
reason string
cause error
key bool
}
// Field function returns field value.
func (e UpdatePersistentCacheTaskRequestValidationError) Field() string { return e.field }
// Reason function returns reason value.
func (e UpdatePersistentCacheTaskRequestValidationError) Reason() string { return e.reason }
// Cause function returns cause value.
func (e UpdatePersistentCacheTaskRequestValidationError) Cause() error { return e.cause }
// Key function returns key value.
func (e UpdatePersistentCacheTaskRequestValidationError) Key() bool { return e.key }
// ErrorName returns error name.
func (e UpdatePersistentCacheTaskRequestValidationError) ErrorName() string {
return "UpdatePersistentCacheTaskRequestValidationError"
}
// Error satisfies the builtin error interface
func (e UpdatePersistentCacheTaskRequestValidationError) Error() string {
cause := ""
if e.cause != nil {
cause = fmt.Sprintf(" | caused by: %v", e.cause)
}
key := ""
if e.key {
key = "key for "
}
return fmt.Sprintf(
"invalid %sUpdatePersistentCacheTaskRequest.%s: %s%s",
key,
e.field,
e.reason,
cause)
}
var _ error = UpdatePersistentCacheTaskRequestValidationError{}
var _ interface {
Field() string
Reason() string
Key() bool
Cause() error
ErrorName() string
} = UpdatePersistentCacheTaskRequestValidationError{}
// Validate checks the field values on StatTaskRequest with the rules defined
// in the proto definition for this message. If any rules are violated, the
// first error encountered is returned, or nil if there are no violations.

View File

@ -113,14 +113,6 @@ message UploadTaskRequest {
common.v2.Task task = 1 [(validate.rules).message.required = true];
}
// UpdatePersistentCacheTaskRequest represents request of UpdatePersistentCacheTask.
message UpdatePersistentCacheTaskRequest {
// Task id.
string task_id = 1 [(validate.rules).string.min_len = 1];
// Set the value of persistent for the persistent cache task.
bool persistent = 2;
}
// StatTaskRequest represents request of StatTask.
message StatTaskRequest {
// Task id.
@ -268,9 +260,6 @@ service DfdaemonUpload {
// DownloadPersistentCacheTask downloads persistent cache task from p2p network.
rpc DownloadPersistentCacheTask(DownloadPersistentCacheTaskRequest) returns(stream DownloadPersistentCacheTaskResponse);
// UpdatePersistentCacheTask updates metadata of the persistent cache task in the peer.
rpc UpdatePersistentCacheTask(UpdatePersistentCacheTaskRequest) returns(google.protobuf.Empty);
// StatPersistentCacheTask stats persistent cache task information.
rpc StatPersistentCacheTask(StatPersistentCacheTaskRequest) returns(common.v2.PersistentCacheTask);

View File

@ -36,8 +36,6 @@ type DfdaemonUploadClient interface {
DownloadPiece(ctx context.Context, in *DownloadPieceRequest, opts ...grpc.CallOption) (*DownloadPieceResponse, error)
// DownloadPersistentCacheTask downloads persistent cache task from p2p network.
DownloadPersistentCacheTask(ctx context.Context, in *DownloadPersistentCacheTaskRequest, opts ...grpc.CallOption) (DfdaemonUpload_DownloadPersistentCacheTaskClient, error)
// UpdatePersistentCacheTask updates metadata of the persistent cache task in the peer.
UpdatePersistentCacheTask(ctx context.Context, in *UpdatePersistentCacheTaskRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
// StatPersistentCacheTask stats persistent cache task information.
StatPersistentCacheTask(ctx context.Context, in *StatPersistentCacheTaskRequest, opts ...grpc.CallOption) (*v2.PersistentCacheTask, error)
// DeletePersistentCacheTask deletes persistent cache task from p2p network.
@ -181,15 +179,6 @@ func (x *dfdaemonUploadDownloadPersistentCacheTaskClient) Recv() (*DownloadPersi
return m, nil
}
func (c *dfdaemonUploadClient) UpdatePersistentCacheTask(ctx context.Context, in *UpdatePersistentCacheTaskRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) {
out := new(emptypb.Empty)
err := c.cc.Invoke(ctx, "/dfdaemon.v2.DfdaemonUpload/UpdatePersistentCacheTask", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *dfdaemonUploadClient) StatPersistentCacheTask(ctx context.Context, in *StatPersistentCacheTaskRequest, opts ...grpc.CallOption) (*v2.PersistentCacheTask, error) {
out := new(v2.PersistentCacheTask)
err := c.cc.Invoke(ctx, "/dfdaemon.v2.DfdaemonUpload/StatPersistentCacheTask", in, out, opts...)
@ -297,8 +286,6 @@ type DfdaemonUploadServer interface {
DownloadPiece(context.Context, *DownloadPieceRequest) (*DownloadPieceResponse, error)
// DownloadPersistentCacheTask downloads persistent cache task from p2p network.
DownloadPersistentCacheTask(*DownloadPersistentCacheTaskRequest, DfdaemonUpload_DownloadPersistentCacheTaskServer) error
// UpdatePersistentCacheTask updates metadata of the persistent cache task in the peer.
UpdatePersistentCacheTask(context.Context, *UpdatePersistentCacheTaskRequest) (*emptypb.Empty, error)
// StatPersistentCacheTask stats persistent cache task information.
StatPersistentCacheTask(context.Context, *StatPersistentCacheTaskRequest) (*v2.PersistentCacheTask, error)
// DeletePersistentCacheTask deletes persistent cache task from p2p network.
@ -333,9 +320,6 @@ func (UnimplementedDfdaemonUploadServer) DownloadPiece(context.Context, *Downloa
func (UnimplementedDfdaemonUploadServer) DownloadPersistentCacheTask(*DownloadPersistentCacheTaskRequest, DfdaemonUpload_DownloadPersistentCacheTaskServer) error {
return status.Errorf(codes.Unimplemented, "method DownloadPersistentCacheTask not implemented")
}
func (UnimplementedDfdaemonUploadServer) UpdatePersistentCacheTask(context.Context, *UpdatePersistentCacheTaskRequest) (*emptypb.Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method UpdatePersistentCacheTask not implemented")
}
func (UnimplementedDfdaemonUploadServer) StatPersistentCacheTask(context.Context, *StatPersistentCacheTaskRequest) (*v2.PersistentCacheTask, error) {
return nil, status.Errorf(codes.Unimplemented, "method StatPersistentCacheTask not implemented")
}
@ -480,24 +464,6 @@ func (x *dfdaemonUploadDownloadPersistentCacheTaskServer) Send(m *DownloadPersis
return x.ServerStream.SendMsg(m)
}
func _DfdaemonUpload_UpdatePersistentCacheTask_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(UpdatePersistentCacheTaskRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(DfdaemonUploadServer).UpdatePersistentCacheTask(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/dfdaemon.v2.DfdaemonUpload/UpdatePersistentCacheTask",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(DfdaemonUploadServer).UpdatePersistentCacheTask(ctx, req.(*UpdatePersistentCacheTaskRequest))
}
return interceptor(ctx, in, info, handler)
}
func _DfdaemonUpload_StatPersistentCacheTask_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(StatPersistentCacheTaskRequest)
if err := dec(in); err != nil {
@ -613,10 +579,6 @@ var DfdaemonUpload_ServiceDesc = grpc.ServiceDesc{
MethodName: "DownloadPiece",
Handler: _DfdaemonUpload_DownloadPiece_Handler,
},
{
MethodName: "UpdatePersistentCacheTask",
Handler: _DfdaemonUpload_UpdatePersistentCacheTask_Handler,
},
{
MethodName: "StatPersistentCacheTask",
Handler: _DfdaemonUpload_StatPersistentCacheTask_Handler,

View File

@ -265,26 +265,6 @@ func (mr *MockDfdaemonUploadClientMockRecorder) SyncPieces(ctx, in any, opts ...
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SyncPieces", reflect.TypeOf((*MockDfdaemonUploadClient)(nil).SyncPieces), varargs...)
}
// UpdatePersistentCacheTask mocks base method.
func (m *MockDfdaemonUploadClient) UpdatePersistentCacheTask(ctx context.Context, in *dfdaemon.UpdatePersistentCacheTaskRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) {
m.ctrl.T.Helper()
varargs := []any{ctx, in}
for _, a := range opts {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "UpdatePersistentCacheTask", varargs...)
ret0, _ := ret[0].(*emptypb.Empty)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// UpdatePersistentCacheTask indicates an expected call of UpdatePersistentCacheTask.
func (mr *MockDfdaemonUploadClientMockRecorder) UpdatePersistentCacheTask(ctx, in any, opts ...any) *gomock.Call {
mr.mock.ctrl.T.Helper()
varargs := append([]any{ctx, in}, opts...)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdatePersistentCacheTask", reflect.TypeOf((*MockDfdaemonUploadClient)(nil).UpdatePersistentCacheTask), varargs...)
}
// MockDfdaemonUpload_DownloadTaskClient is a mock of DfdaemonUpload_DownloadTaskClient interface.
type MockDfdaemonUpload_DownloadTaskClient struct {
ctrl *gomock.Controller
@ -1089,21 +1069,6 @@ func (mr *MockDfdaemonUploadServerMockRecorder) SyncPieces(arg0, arg1 any) *gomo
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SyncPieces", reflect.TypeOf((*MockDfdaemonUploadServer)(nil).SyncPieces), arg0, arg1)
}
// UpdatePersistentCacheTask mocks base method.
func (m *MockDfdaemonUploadServer) UpdatePersistentCacheTask(arg0 context.Context, arg1 *dfdaemon.UpdatePersistentCacheTaskRequest) (*emptypb.Empty, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "UpdatePersistentCacheTask", arg0, arg1)
ret0, _ := ret[0].(*emptypb.Empty)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// UpdatePersistentCacheTask indicates an expected call of UpdatePersistentCacheTask.
func (mr *MockDfdaemonUploadServerMockRecorder) UpdatePersistentCacheTask(arg0, arg1 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdatePersistentCacheTask", reflect.TypeOf((*MockDfdaemonUploadServer)(nil).UpdatePersistentCacheTask), arg0, arg1)
}
// MockUnsafeDfdaemonUploadServer is a mock of UnsafeDfdaemonUploadServer interface.
type MockUnsafeDfdaemonUploadServer struct {
ctrl *gomock.Controller

View File

@ -171,14 +171,6 @@ message UploadPersistentCacheTaskRequest {
optional google.protobuf.Duration timeout = 6;
}
// UpdatePersistentCacheTaskRequest represents request of UpdatePersistentCacheTask.
message UpdatePersistentCacheTaskRequest {
// Task id.
string task_id = 1;
// Set the value of persistent for the persistent cache task.
bool persistent = 2;
}
// StatPersistentCacheTaskRequest represents request of StatPersistentCacheTask.
message StatPersistentCacheTaskRequest {
// Task id.
@ -255,9 +247,6 @@ service DfdaemonUpload{
// DownloadPersistentCacheTask downloads persistent cache task from p2p network.
rpc DownloadPersistentCacheTask(DownloadPersistentCacheTaskRequest) returns(stream DownloadPersistentCacheTaskResponse);
// UpdatePersistentCacheTask updates metadata of the persistent cache task in the peer.
rpc UpdatePersistentCacheTask(UpdatePersistentCacheTaskRequest) returns(google.protobuf.Empty);
// StatPersistentCacheTask stats persistent cache task information.
rpc StatPersistentCacheTask(StatPersistentCacheTaskRequest) returns(common.v2.PersistentCacheTask);

Binary file not shown.

View File

@ -236,18 +236,6 @@ pub struct UploadPersistentCacheTaskRequest {
#[prost(message, optional, tag = "6")]
pub timeout: ::core::option::Option<::prost_wkt_types::Duration>,
}
/// UpdatePersistentCacheTaskRequest represents request of UpdatePersistentCacheTask.
#[derive(serde::Serialize, serde::Deserialize)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct UpdatePersistentCacheTaskRequest {
/// Task id.
#[prost(string, tag = "1")]
pub task_id: ::prost::alloc::string::String,
/// Set the value of persistent for the persistent cache task.
#[prost(bool, tag = "2")]
pub persistent: bool,
}
/// StatPersistentCacheTaskRequest represents request of StatPersistentCacheTask.
#[derive(serde::Serialize, serde::Deserialize)]
#[allow(clippy::derive_partial_eq_without_eq)]
@ -578,34 +566,6 @@ pub mod dfdaemon_upload_client {
);
self.inner.server_streaming(req, path, codec).await
}
/// UpdatePersistentCacheTask updates metadata of the persistent cache task in the peer.
pub async fn update_persistent_cache_task(
&mut self,
request: impl tonic::IntoRequest<super::UpdatePersistentCacheTaskRequest>,
) -> std::result::Result<tonic::Response<()>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/dfdaemon.v2.DfdaemonUpload/UpdatePersistentCacheTask",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"dfdaemon.v2.DfdaemonUpload",
"UpdatePersistentCacheTask",
),
);
self.inner.unary(req, path, codec).await
}
/// StatPersistentCacheTask stats persistent cache task information.
pub async fn stat_persistent_cache_task(
&mut self,
@ -1138,11 +1098,6 @@ pub mod dfdaemon_upload_server {
tonic::Response<Self::DownloadPersistentCacheTaskStream>,
tonic::Status,
>;
/// UpdatePersistentCacheTask updates metadata of the persistent cache task in the peer.
async fn update_persistent_cache_task(
&self,
request: tonic::Request<super::UpdatePersistentCacheTaskRequest>,
) -> std::result::Result<tonic::Response<()>, tonic::Status>;
/// StatPersistentCacheTask stats persistent cache task information.
async fn stat_persistent_cache_task(
&self,
@ -1553,58 +1508,6 @@ pub mod dfdaemon_upload_server {
};
Box::pin(fut)
}
"/dfdaemon.v2.DfdaemonUpload/UpdatePersistentCacheTask" => {
#[allow(non_camel_case_types)]
struct UpdatePersistentCacheTaskSvc<T: DfdaemonUpload>(pub Arc<T>);
impl<
T: DfdaemonUpload,
> tonic::server::UnaryService<
super::UpdatePersistentCacheTaskRequest,
> for UpdatePersistentCacheTaskSvc<T> {
type Response = ();
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<
super::UpdatePersistentCacheTaskRequest,
>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as DfdaemonUpload>::update_persistent_cache_task(
&inner,
request,
)
.await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = UpdatePersistentCacheTaskSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/dfdaemon.v2.DfdaemonUpload/StatPersistentCacheTask" => {
#[allow(non_camel_case_types)]
struct StatPersistentCacheTaskSvc<T: DfdaemonUpload>(pub Arc<T>);