diff --git a/pkg/apis/dfdaemon/v1/dfdaemon.pb.go b/pkg/apis/dfdaemon/v1/dfdaemon.pb.go index be287df..4afe2e2 100644 --- a/pkg/apis/dfdaemon/v1/dfdaemon.pb.go +++ b/pkg/apis/dfdaemon/v1/dfdaemon.pb.go @@ -38,6 +38,62 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +// PeerState represents state of peer task. +type PeerState int32 + +const ( + PeerState_Unknown PeerState = 0 + PeerState_Running PeerState = 1 + PeerState_Success PeerState = 2 + PeerState_Failed PeerState = 3 + PeerState_Deleted PeerState = 4 +) + +// Enum value maps for PeerState. +var ( + PeerState_name = map[int32]string{ + 0: "Unknown", + 1: "Running", + 2: "Success", + 3: "Failed", + 4: "Deleted", + } + PeerState_value = map[string]int32{ + "Unknown": 0, + "Running": 1, + "Success": 2, + "Failed": 3, + "Deleted": 4, + } +) + +func (x PeerState) Enum() *PeerState { + p := new(PeerState) + *p = x + return p +} + +func (x PeerState) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (PeerState) Descriptor() protoreflect.EnumDescriptor { + return file_pkg_apis_dfdaemon_v1_dfdaemon_proto_enumTypes[0].Descriptor() +} + +func (PeerState) Type() protoreflect.EnumType { + return &file_pkg_apis_dfdaemon_v1_dfdaemon_proto_enumTypes[0] +} + +func (x PeerState) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use PeerState.Descriptor instead. +func (PeerState) EnumDescriptor() ([]byte, []int) { + return file_pkg_apis_dfdaemon_v1_dfdaemon_proto_rawDescGZIP(), []int{0} +} + type DownRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -571,6 +627,70 @@ func (x *DeleteTaskRequest) GetUrlMeta() *v1.UrlMeta { return nil } +// Peer represents metadata of a peer task. +type PeerMetadata struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + TaskId string `protobuf:"bytes,1,opt,name=task_id,json=taskId,proto3" json:"task_id,omitempty"` + PeerId string `protobuf:"bytes,2,opt,name=peer_id,json=peerId,proto3" json:"peer_id,omitempty"` + State PeerState `protobuf:"varint,3,opt,name=state,proto3,enum=dfdaemon.PeerState" json:"state,omitempty"` +} + +func (x *PeerMetadata) Reset() { + *x = PeerMetadata{} + if protoimpl.UnsafeEnabled { + mi := &file_pkg_apis_dfdaemon_v1_dfdaemon_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PeerMetadata) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PeerMetadata) ProtoMessage() {} + +func (x *PeerMetadata) ProtoReflect() protoreflect.Message { + mi := &file_pkg_apis_dfdaemon_v1_dfdaemon_proto_msgTypes[6] + 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 PeerMetadata.ProtoReflect.Descriptor instead. +func (*PeerMetadata) Descriptor() ([]byte, []int) { + return file_pkg_apis_dfdaemon_v1_dfdaemon_proto_rawDescGZIP(), []int{6} +} + +func (x *PeerMetadata) GetTaskId() string { + if x != nil { + return x.TaskId + } + return "" +} + +func (x *PeerMetadata) GetPeerId() string { + if x != nil { + return x.PeerId + } + return "" +} + +func (x *PeerMetadata) GetState() PeerState { + if x != nil { + return x.State + } + return PeerState_Unknown +} + var File_pkg_apis_dfdaemon_v1_dfdaemon_proto protoreflect.FileDescriptor var file_pkg_apis_dfdaemon_v1_dfdaemon_proto_rawDesc = []byte{ @@ -660,40 +780,57 @@ var file_pkg_apis_dfdaemon_v1_dfdaemon_proto_rawDesc = []byte{ 0x34, 0x0a, 0x08, 0x75, 0x72, 0x6c, 0x5f, 0x6d, 0x65, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x55, 0x72, 0x6c, 0x4d, 0x65, 0x74, 0x61, 0x42, 0x08, 0xfa, 0x42, 0x05, 0x8a, 0x01, 0x02, 0x10, 0x01, 0x52, 0x07, 0x75, 0x72, - 0x6c, 0x4d, 0x65, 0x74, 0x61, 0x32, 0x8f, 0x04, 0x0a, 0x06, 0x44, 0x61, 0x65, 0x6d, 0x6f, 0x6e, - 0x12, 0x39, 0x0a, 0x08, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x15, 0x2e, 0x64, - 0x66, 0x64, 0x61, 0x65, 0x6d, 0x6f, 0x6e, 0x2e, 0x44, 0x6f, 0x77, 0x6e, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x64, 0x66, 0x64, 0x61, 0x65, 0x6d, 0x6f, 0x6e, 0x2e, 0x44, - 0x6f, 0x77, 0x6e, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x30, 0x01, 0x12, 0x3e, 0x0a, 0x0d, 0x47, - 0x65, 0x74, 0x50, 0x69, 0x65, 0x63, 0x65, 0x54, 0x61, 0x73, 0x6b, 0x73, 0x12, 0x18, 0x2e, 0x63, - 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x50, 0x69, 0x65, 0x63, 0x65, 0x54, 0x61, 0x73, 0x6b, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, - 0x50, 0x69, 0x65, 0x63, 0x65, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x12, 0x3d, 0x0a, 0x0b, 0x43, - 0x68, 0x65, 0x63, 0x6b, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, - 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, - 0x74, 0x79, 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, 0x43, 0x0a, 0x0e, 0x53, 0x79, - 0x6e, 0x63, 0x50, 0x69, 0x65, 0x63, 0x65, 0x54, 0x61, 0x73, 0x6b, 0x73, 0x12, 0x18, 0x2e, 0x63, - 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x50, 0x69, 0x65, 0x63, 0x65, 0x54, 0x61, 0x73, 0x6b, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, - 0x50, 0x69, 0x65, 0x63, 0x65, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x28, 0x01, 0x30, 0x01, 0x12, - 0x3d, 0x0a, 0x08, 0x53, 0x74, 0x61, 0x74, 0x54, 0x61, 0x73, 0x6b, 0x12, 0x19, 0x2e, 0x64, 0x66, - 0x64, 0x61, 0x65, 0x6d, 0x6f, 0x6e, 0x2e, 0x53, 0x74, 0x61, 0x74, 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, 0x41, - 0x0a, 0x0a, 0x49, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x54, 0x61, 0x73, 0x6b, 0x12, 0x1b, 0x2e, 0x64, - 0x66, 0x64, 0x61, 0x65, 0x6d, 0x6f, 0x6e, 0x2e, 0x49, 0x6d, 0x70, 0x6f, 0x72, 0x74, 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, 0x41, 0x0a, 0x0a, 0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x54, 0x61, 0x73, 0x6b, 0x12, - 0x1b, 0x2e, 0x64, 0x66, 0x64, 0x61, 0x65, 0x6d, 0x6f, 0x6e, 0x2e, 0x45, 0x78, 0x70, 0x6f, 0x72, - 0x74, 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, 0x41, 0x0a, 0x0a, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x54, 0x61, - 0x73, 0x6b, 0x12, 0x1b, 0x2e, 0x64, 0x66, 0x64, 0x61, 0x65, 0x6d, 0x6f, 0x6e, 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, + 0x6c, 0x4d, 0x65, 0x74, 0x61, 0x22, 0x7d, 0x0a, 0x0c, 0x50, 0x65, 0x65, 0x72, 0x4d, 0x65, 0x74, + 0x61, 0x64, 0x61, 0x74, 0x61, 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, 0x12, 0x20, 0x0a, 0x07, 0x70, 0x65, 0x65, 0x72, 0x5f, + 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, + 0x01, 0x52, 0x06, 0x70, 0x65, 0x65, 0x72, 0x49, 0x64, 0x12, 0x29, 0x0a, 0x05, 0x73, 0x74, 0x61, + 0x74, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x13, 0x2e, 0x64, 0x66, 0x64, 0x61, 0x65, + 0x6d, 0x6f, 0x6e, 0x2e, 0x50, 0x65, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x05, 0x73, + 0x74, 0x61, 0x74, 0x65, 0x2a, 0x4b, 0x0a, 0x09, 0x50, 0x65, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, + 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x0b, + 0x0a, 0x07, 0x52, 0x75, 0x6e, 0x6e, 0x69, 0x6e, 0x67, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x53, + 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, 0x46, 0x61, 0x69, 0x6c, + 0x65, 0x64, 0x10, 0x03, 0x12, 0x0b, 0x0a, 0x07, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x10, + 0x04, 0x32, 0xd3, 0x04, 0x0a, 0x06, 0x44, 0x61, 0x65, 0x6d, 0x6f, 0x6e, 0x12, 0x39, 0x0a, 0x08, + 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x15, 0x2e, 0x64, 0x66, 0x64, 0x61, 0x65, + 0x6d, 0x6f, 0x6e, 0x2e, 0x44, 0x6f, 0x77, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x14, 0x2e, 0x64, 0x66, 0x64, 0x61, 0x65, 0x6d, 0x6f, 0x6e, 0x2e, 0x44, 0x6f, 0x77, 0x6e, 0x52, + 0x65, 0x73, 0x75, 0x6c, 0x74, 0x30, 0x01, 0x12, 0x3e, 0x0a, 0x0d, 0x47, 0x65, 0x74, 0x50, 0x69, + 0x65, 0x63, 0x65, 0x54, 0x61, 0x73, 0x6b, 0x73, 0x12, 0x18, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, + 0x6e, 0x2e, 0x50, 0x69, 0x65, 0x63, 0x65, 0x54, 0x61, 0x73, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x50, 0x69, 0x65, 0x63, + 0x65, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x12, 0x3d, 0x0a, 0x0b, 0x43, 0x68, 0x65, 0x63, 0x6b, + 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 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, 0x43, 0x0a, 0x0e, 0x53, 0x79, 0x6e, 0x63, 0x50, 0x69, + 0x65, 0x63, 0x65, 0x54, 0x61, 0x73, 0x6b, 0x73, 0x12, 0x18, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, + 0x6e, 0x2e, 0x50, 0x69, 0x65, 0x63, 0x65, 0x54, 0x61, 0x73, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x50, 0x69, 0x65, 0x63, + 0x65, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x28, 0x01, 0x30, 0x01, 0x12, 0x3d, 0x0a, 0x08, 0x53, + 0x74, 0x61, 0x74, 0x54, 0x61, 0x73, 0x6b, 0x12, 0x19, 0x2e, 0x64, 0x66, 0x64, 0x61, 0x65, 0x6d, + 0x6f, 0x6e, 0x2e, 0x53, 0x74, 0x61, 0x74, 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, 0x41, 0x0a, 0x0a, 0x49, 0x6d, + 0x70, 0x6f, 0x72, 0x74, 0x54, 0x61, 0x73, 0x6b, 0x12, 0x1b, 0x2e, 0x64, 0x66, 0x64, 0x61, 0x65, + 0x6d, 0x6f, 0x6e, 0x2e, 0x49, 0x6d, 0x70, 0x6f, 0x72, 0x74, 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, 0x41, 0x0a, + 0x0a, 0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x54, 0x61, 0x73, 0x6b, 0x12, 0x1b, 0x2e, 0x64, 0x66, + 0x64, 0x61, 0x65, 0x6d, 0x6f, 0x6e, 0x2e, 0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, 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, 0x41, 0x0a, 0x0a, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x54, 0x61, 0x73, 0x6b, 0x12, 0x1b, + 0x2e, 0x64, 0x66, 0x64, 0x61, 0x65, 0x6d, 0x6f, 0x6e, 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, 0x12, 0x42, 0x0a, 0x0c, 0x50, 0x65, 0x65, 0x72, 0x45, 0x78, 0x63, 0x68, 0x61, + 0x6e, 0x67, 0x65, 0x12, 0x16, 0x2e, 0x64, 0x66, 0x64, 0x61, 0x65, 0x6d, 0x6f, 0x6e, 0x2e, 0x50, + 0x65, 0x65, 0x72, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x1a, 0x16, 0x2e, 0x64, 0x66, + 0x64, 0x61, 0x65, 0x6d, 0x6f, 0x6e, 0x2e, 0x50, 0x65, 0x65, 0x72, 0x4d, 0x65, 0x74, 0x61, 0x64, + 0x61, 0x74, 0x61, 0x28, 0x01, 0x30, 0x01, 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, 0x31, 0x3b, 0x64, 0x66, 0x64, 0x61, 0x65, 0x6d, 0x6f, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, @@ -711,48 +848,54 @@ func file_pkg_apis_dfdaemon_v1_dfdaemon_proto_rawDescGZIP() []byte { return file_pkg_apis_dfdaemon_v1_dfdaemon_proto_rawDescData } -var file_pkg_apis_dfdaemon_v1_dfdaemon_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_pkg_apis_dfdaemon_v1_dfdaemon_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_pkg_apis_dfdaemon_v1_dfdaemon_proto_msgTypes = make([]protoimpl.MessageInfo, 7) var file_pkg_apis_dfdaemon_v1_dfdaemon_proto_goTypes = []interface{}{ - (*DownRequest)(nil), // 0: dfdaemon.DownRequest - (*DownResult)(nil), // 1: dfdaemon.DownResult - (*StatTaskRequest)(nil), // 2: dfdaemon.StatTaskRequest - (*ImportTaskRequest)(nil), // 3: dfdaemon.ImportTaskRequest - (*ExportTaskRequest)(nil), // 4: dfdaemon.ExportTaskRequest - (*DeleteTaskRequest)(nil), // 5: dfdaemon.DeleteTaskRequest - (*v1.UrlMeta)(nil), // 6: common.UrlMeta - (v1.TaskType)(0), // 7: common.TaskType - (*v1.PieceTaskRequest)(nil), // 8: common.PieceTaskRequest - (*emptypb.Empty)(nil), // 9: google.protobuf.Empty - (*v1.PiecePacket)(nil), // 10: common.PiecePacket + (PeerState)(0), // 0: dfdaemon.PeerState + (*DownRequest)(nil), // 1: dfdaemon.DownRequest + (*DownResult)(nil), // 2: dfdaemon.DownResult + (*StatTaskRequest)(nil), // 3: dfdaemon.StatTaskRequest + (*ImportTaskRequest)(nil), // 4: dfdaemon.ImportTaskRequest + (*ExportTaskRequest)(nil), // 5: dfdaemon.ExportTaskRequest + (*DeleteTaskRequest)(nil), // 6: dfdaemon.DeleteTaskRequest + (*PeerMetadata)(nil), // 7: dfdaemon.PeerMetadata + (*v1.UrlMeta)(nil), // 8: common.UrlMeta + (v1.TaskType)(0), // 9: common.TaskType + (*v1.PieceTaskRequest)(nil), // 10: common.PieceTaskRequest + (*emptypb.Empty)(nil), // 11: google.protobuf.Empty + (*v1.PiecePacket)(nil), // 12: common.PiecePacket } var file_pkg_apis_dfdaemon_v1_dfdaemon_proto_depIdxs = []int32{ - 6, // 0: dfdaemon.DownRequest.url_meta:type_name -> common.UrlMeta - 6, // 1: dfdaemon.StatTaskRequest.url_meta:type_name -> common.UrlMeta - 6, // 2: dfdaemon.ImportTaskRequest.url_meta:type_name -> common.UrlMeta - 7, // 3: dfdaemon.ImportTaskRequest.type:type_name -> common.TaskType - 6, // 4: dfdaemon.ExportTaskRequest.url_meta:type_name -> common.UrlMeta - 6, // 5: dfdaemon.DeleteTaskRequest.url_meta:type_name -> common.UrlMeta - 0, // 6: dfdaemon.Daemon.Download:input_type -> dfdaemon.DownRequest - 8, // 7: dfdaemon.Daemon.GetPieceTasks:input_type -> common.PieceTaskRequest - 9, // 8: dfdaemon.Daemon.CheckHealth:input_type -> google.protobuf.Empty - 8, // 9: dfdaemon.Daemon.SyncPieceTasks:input_type -> common.PieceTaskRequest - 2, // 10: dfdaemon.Daemon.StatTask:input_type -> dfdaemon.StatTaskRequest - 3, // 11: dfdaemon.Daemon.ImportTask:input_type -> dfdaemon.ImportTaskRequest - 4, // 12: dfdaemon.Daemon.ExportTask:input_type -> dfdaemon.ExportTaskRequest - 5, // 13: dfdaemon.Daemon.DeleteTask:input_type -> dfdaemon.DeleteTaskRequest - 1, // 14: dfdaemon.Daemon.Download:output_type -> dfdaemon.DownResult - 10, // 15: dfdaemon.Daemon.GetPieceTasks:output_type -> common.PiecePacket - 9, // 16: dfdaemon.Daemon.CheckHealth:output_type -> google.protobuf.Empty - 10, // 17: dfdaemon.Daemon.SyncPieceTasks:output_type -> common.PiecePacket - 9, // 18: dfdaemon.Daemon.StatTask:output_type -> google.protobuf.Empty - 9, // 19: dfdaemon.Daemon.ImportTask:output_type -> google.protobuf.Empty - 9, // 20: dfdaemon.Daemon.ExportTask:output_type -> google.protobuf.Empty - 9, // 21: dfdaemon.Daemon.DeleteTask:output_type -> google.protobuf.Empty - 14, // [14:22] is the sub-list for method output_type - 6, // [6:14] is the sub-list for method input_type - 6, // [6:6] is the sub-list for extension type_name - 6, // [6:6] is the sub-list for extension extendee - 0, // [0:6] is the sub-list for field type_name + 8, // 0: dfdaemon.DownRequest.url_meta:type_name -> common.UrlMeta + 8, // 1: dfdaemon.StatTaskRequest.url_meta:type_name -> common.UrlMeta + 8, // 2: dfdaemon.ImportTaskRequest.url_meta:type_name -> common.UrlMeta + 9, // 3: dfdaemon.ImportTaskRequest.type:type_name -> common.TaskType + 8, // 4: dfdaemon.ExportTaskRequest.url_meta:type_name -> common.UrlMeta + 8, // 5: dfdaemon.DeleteTaskRequest.url_meta:type_name -> common.UrlMeta + 0, // 6: dfdaemon.PeerMetadata.state:type_name -> dfdaemon.PeerState + 1, // 7: dfdaemon.Daemon.Download:input_type -> dfdaemon.DownRequest + 10, // 8: dfdaemon.Daemon.GetPieceTasks:input_type -> common.PieceTaskRequest + 11, // 9: dfdaemon.Daemon.CheckHealth:input_type -> google.protobuf.Empty + 10, // 10: dfdaemon.Daemon.SyncPieceTasks:input_type -> common.PieceTaskRequest + 3, // 11: dfdaemon.Daemon.StatTask:input_type -> dfdaemon.StatTaskRequest + 4, // 12: dfdaemon.Daemon.ImportTask:input_type -> dfdaemon.ImportTaskRequest + 5, // 13: dfdaemon.Daemon.ExportTask:input_type -> dfdaemon.ExportTaskRequest + 6, // 14: dfdaemon.Daemon.DeleteTask:input_type -> dfdaemon.DeleteTaskRequest + 7, // 15: dfdaemon.Daemon.PeerExchange:input_type -> dfdaemon.PeerMetadata + 2, // 16: dfdaemon.Daemon.Download:output_type -> dfdaemon.DownResult + 12, // 17: dfdaemon.Daemon.GetPieceTasks:output_type -> common.PiecePacket + 11, // 18: dfdaemon.Daemon.CheckHealth:output_type -> google.protobuf.Empty + 12, // 19: dfdaemon.Daemon.SyncPieceTasks:output_type -> common.PiecePacket + 11, // 20: dfdaemon.Daemon.StatTask:output_type -> google.protobuf.Empty + 11, // 21: dfdaemon.Daemon.ImportTask:output_type -> google.protobuf.Empty + 11, // 22: dfdaemon.Daemon.ExportTask:output_type -> google.protobuf.Empty + 11, // 23: dfdaemon.Daemon.DeleteTask:output_type -> google.protobuf.Empty + 7, // 24: dfdaemon.Daemon.PeerExchange:output_type -> dfdaemon.PeerMetadata + 16, // [16:25] is the sub-list for method output_type + 7, // [7:16] is the sub-list for method input_type + 7, // [7:7] is the sub-list for extension type_name + 7, // [7:7] is the sub-list for extension extendee + 0, // [0:7] is the sub-list for field type_name } func init() { file_pkg_apis_dfdaemon_v1_dfdaemon_proto_init() } @@ -833,19 +976,32 @@ func file_pkg_apis_dfdaemon_v1_dfdaemon_proto_init() { return nil } } + file_pkg_apis_dfdaemon_v1_dfdaemon_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PeerMetadata); 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_pkg_apis_dfdaemon_v1_dfdaemon_proto_rawDesc, - NumEnums: 0, - NumMessages: 6, + NumEnums: 1, + NumMessages: 7, NumExtensions: 0, NumServices: 1, }, GoTypes: file_pkg_apis_dfdaemon_v1_dfdaemon_proto_goTypes, DependencyIndexes: file_pkg_apis_dfdaemon_v1_dfdaemon_proto_depIdxs, + EnumInfos: file_pkg_apis_dfdaemon_v1_dfdaemon_proto_enumTypes, MessageInfos: file_pkg_apis_dfdaemon_v1_dfdaemon_proto_msgTypes, }.Build() File_pkg_apis_dfdaemon_v1_dfdaemon_proto = out.File diff --git a/pkg/apis/dfdaemon/v1/dfdaemon.pb.validate.go b/pkg/apis/dfdaemon/v1/dfdaemon.pb.validate.go index 4f710a2..c5ddf74 100644 --- a/pkg/apis/dfdaemon/v1/dfdaemon.pb.validate.go +++ b/pkg/apis/dfdaemon/v1/dfdaemon.pb.validate.go @@ -1043,3 +1043,126 @@ var _ interface { Cause() error ErrorName() string } = DeleteTaskRequestValidationError{} + +// Validate checks the field values on PeerMetadata 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 *PeerMetadata) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on PeerMetadata 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 PeerMetadataMultiError, or +// nil if none found. +func (m *PeerMetadata) ValidateAll() error { + return m.validate(true) +} + +func (m *PeerMetadata) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if utf8.RuneCountInString(m.GetTaskId()) < 1 { + err := PeerMetadataValidationError{ + field: "TaskId", + reason: "value length must be at least 1 runes", + } + if !all { + return err + } + errors = append(errors, err) + } + + if utf8.RuneCountInString(m.GetPeerId()) < 1 { + err := PeerMetadataValidationError{ + field: "PeerId", + reason: "value length must be at least 1 runes", + } + if !all { + return err + } + errors = append(errors, err) + } + + // no validation rules for State + + if len(errors) > 0 { + return PeerMetadataMultiError(errors) + } + + return nil +} + +// PeerMetadataMultiError is an error wrapping multiple validation errors +// returned by PeerMetadata.ValidateAll() if the designated constraints aren't met. +type PeerMetadataMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m PeerMetadataMultiError) 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 PeerMetadataMultiError) AllErrors() []error { return m } + +// PeerMetadataValidationError is the validation error returned by +// PeerMetadata.Validate if the designated constraints aren't met. +type PeerMetadataValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e PeerMetadataValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e PeerMetadataValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e PeerMetadataValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e PeerMetadataValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e PeerMetadataValidationError) ErrorName() string { return "PeerMetadataValidationError" } + +// Error satisfies the builtin error interface +func (e PeerMetadataValidationError) 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 %sPeerMetadata.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = PeerMetadataValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = PeerMetadataValidationError{} diff --git a/pkg/apis/dfdaemon/v1/dfdaemon.proto b/pkg/apis/dfdaemon/v1/dfdaemon.proto index d134079..99cec39 100644 --- a/pkg/apis/dfdaemon/v1/dfdaemon.proto +++ b/pkg/apis/dfdaemon/v1/dfdaemon.proto @@ -110,6 +110,22 @@ message DeleteTaskRequest{ common.UrlMeta url_meta = 2 [(validate.rules).message.required = true]; } +// PeerState represents state of peer task. +enum PeerState { + Unknown = 0; + Running = 1; + Success = 2; + Failed = 3; + Deleted = 4; +} + +// Peer represents metadata of a peer task. +message PeerMetadata { + string task_id = 1 [(validate.rules).string.min_len = 1]; + string peer_id = 2 [(validate.rules).string.min_len = 1]; + PeerState state = 3; +} + // Daemon Client RPC Service service Daemon{ // Trigger client to download file @@ -128,4 +144,6 @@ service Daemon{ rpc ExportTask(ExportTaskRequest) returns(google.protobuf.Empty); // Delete file from P2P cache system rpc DeleteTask(DeleteTaskRequest) returns(google.protobuf.Empty); + // Exchange peers between daemons + rpc PeerExchange(stream PeerMetadata)returns(stream PeerMetadata); } diff --git a/pkg/apis/dfdaemon/v1/dfdaemon_grpc.pb.go b/pkg/apis/dfdaemon/v1/dfdaemon_grpc.pb.go index 04e6b18..12a8a89 100644 --- a/pkg/apis/dfdaemon/v1/dfdaemon_grpc.pb.go +++ b/pkg/apis/dfdaemon/v1/dfdaemon_grpc.pb.go @@ -40,6 +40,8 @@ type DaemonClient interface { ExportTask(ctx context.Context, in *ExportTaskRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) // Delete file from P2P cache system DeleteTask(ctx context.Context, in *DeleteTaskRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) + // Exchange peers between daemons + PeerExchange(ctx context.Context, opts ...grpc.CallOption) (Daemon_PeerExchangeClient, error) } type daemonClient struct { @@ -167,6 +169,37 @@ func (c *daemonClient) DeleteTask(ctx context.Context, in *DeleteTaskRequest, op return out, nil } +func (c *daemonClient) PeerExchange(ctx context.Context, opts ...grpc.CallOption) (Daemon_PeerExchangeClient, error) { + stream, err := c.cc.NewStream(ctx, &Daemon_ServiceDesc.Streams[2], "/dfdaemon.Daemon/PeerExchange", opts...) + if err != nil { + return nil, err + } + x := &daemonPeerExchangeClient{stream} + return x, nil +} + +type Daemon_PeerExchangeClient interface { + Send(*PeerMetadata) error + Recv() (*PeerMetadata, error) + grpc.ClientStream +} + +type daemonPeerExchangeClient struct { + grpc.ClientStream +} + +func (x *daemonPeerExchangeClient) Send(m *PeerMetadata) error { + return x.ClientStream.SendMsg(m) +} + +func (x *daemonPeerExchangeClient) Recv() (*PeerMetadata, error) { + m := new(PeerMetadata) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + // DaemonServer is the server API for Daemon service. // All implementations should embed UnimplementedDaemonServer // for forward compatibility @@ -187,6 +220,8 @@ type DaemonServer interface { ExportTask(context.Context, *ExportTaskRequest) (*emptypb.Empty, error) // Delete file from P2P cache system DeleteTask(context.Context, *DeleteTaskRequest) (*emptypb.Empty, error) + // Exchange peers between daemons + PeerExchange(Daemon_PeerExchangeServer) error } // UnimplementedDaemonServer should be embedded to have forward compatible implementations. @@ -217,6 +252,9 @@ func (UnimplementedDaemonServer) ExportTask(context.Context, *ExportTaskRequest) func (UnimplementedDaemonServer) DeleteTask(context.Context, *DeleteTaskRequest) (*emptypb.Empty, error) { return nil, status.Errorf(codes.Unimplemented, "method DeleteTask not implemented") } +func (UnimplementedDaemonServer) PeerExchange(Daemon_PeerExchangeServer) error { + return status.Errorf(codes.Unimplemented, "method PeerExchange not implemented") +} // UnsafeDaemonServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to DaemonServer will @@ -384,6 +422,32 @@ func _Daemon_DeleteTask_Handler(srv interface{}, ctx context.Context, dec func(i return interceptor(ctx, in, info, handler) } +func _Daemon_PeerExchange_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(DaemonServer).PeerExchange(&daemonPeerExchangeServer{stream}) +} + +type Daemon_PeerExchangeServer interface { + Send(*PeerMetadata) error + Recv() (*PeerMetadata, error) + grpc.ServerStream +} + +type daemonPeerExchangeServer struct { + grpc.ServerStream +} + +func (x *daemonPeerExchangeServer) Send(m *PeerMetadata) error { + return x.ServerStream.SendMsg(m) +} + +func (x *daemonPeerExchangeServer) Recv() (*PeerMetadata, error) { + m := new(PeerMetadata) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + // Daemon_ServiceDesc is the grpc.ServiceDesc for Daemon service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -428,6 +492,12 @@ var Daemon_ServiceDesc = grpc.ServiceDesc{ ServerStreams: true, ClientStreams: true, }, + { + StreamName: "PeerExchange", + Handler: _Daemon_PeerExchange_Handler, + ServerStreams: true, + ClientStreams: true, + }, }, Metadata: "pkg/apis/dfdaemon/v1/dfdaemon.proto", }