Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add definition of the task type #393

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "dragonfly-api"
version = "2.0.159"
version = "2.0.160"
authors = ["Gaius <[email protected]>"]
edition = "2021"
license = "Apache-2.0"
Expand Down
78 changes: 42 additions & 36 deletions pkg/apis/common/v2/common.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 18 additions & 12 deletions pkg/apis/common/v2/common.proto
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,24 @@ enum SizeScope {

// TaskType represents type of task.
enum TaskType {
// DFDAEMON is dfdaemon type of task,
// dfdaemon task is a normal p2p task.
DFDAEMON = 0;

// DFCACHE is dfcache type of task,
// dfcache task is a cache task, and the task url is fake url.
// It can only be used for caching and cannot be downloaded back to source.
DFCACHE = 1;

// DFSTORE is dfstore type of task,
// dfstore task is a persistent task in backend.
DFSTORE = 2;
// STANDARD is standard type of task, it can download from source, remote peer and
// local peer(local cache). When the standard task is never downloaded in the
// P2P cluster, dfdaemon will download the task from the source. When the standard
// task is downloaded in the P2P cluster, dfdaemon will download the task from
// the remote peer or local peer(local cache).
STANDARD = 0;

// PERSIST is persist type of task, it can import file and export file in P2P cluster.
// When the persist task is imported into the P2P cluster, dfdaemon will store
// the task in the peer's disk and copy multiple replicas to remote peers to
// prevent data loss.
PERSIST = 1;

// PERSIST_CACHE is persist cache type of task, it can import file and export file in P2P cluster.
// When the persist cache task is imported into the P2P cluster, dfdaemon will store
// the task in the peer's disk and copy multiple replicas to remote peers to prevent data loss.
// When the expiration time is reached, task will be deleted in the P2P cluster.
PERSIST_CACHE = 2;
}

// TrafficType represents type of traffic.
Expand Down
30 changes: 18 additions & 12 deletions proto/common.proto
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,24 @@ enum SizeScope {

// TaskType represents type of task.
enum TaskType {
// DFDAEMON is dfdaemon type of task,
// dfdaemon task is a normal p2p task.
DFDAEMON = 0;

// DFCACHE is dfcache type of task,
// dfcache task is a cache task, and the task url is fake url.
// It can only be used for caching and cannot be downloaded back to source.
DFCACHE = 1;

// DFSTORE is dfstore type of task,
// dfstore task is a persistent task in backend.
DFSTORE = 2;
// STANDARD is standard type of task, it can download from source, remote peer and
// local peer(local cache). When the standard task is never downloaded in the
// P2P cluster, dfdaemon will download the task from the source. When the standard
// task is downloaded in the P2P cluster, dfdaemon will download the task from
// the remote peer or local peer(local cache).
STANDARD = 0;

// PERSIST is persist type of task, it can import file and export file in P2P cluster.
// When the persist task is imported into the P2P cluster, dfdaemon will store
// the task in the peer's disk and copy multiple replicas to remote peers to
// prevent data loss.
PERSIST = 1;

// PERSIST_CACHE is persist cache type of task, it can import file and export file in P2P cluster.
// When the persist cache task is imported into the P2P cluster, dfdaemon will store
// the task in the peer's disk and copy multiple replicas to remote peers to prevent data loss.
// When the expiration time is reached, task will be deleted in the P2P cluster.
PERSIST_CACHE = 2;
}

// TrafficType represents type of traffic.
Expand Down
38 changes: 22 additions & 16 deletions src/common.v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -574,16 +574,22 @@ impl SizeScope {
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum TaskType {
/// DFDAEMON is dfdaemon type of task,
/// dfdaemon task is a normal p2p task.
Dfdaemon = 0,
/// DFCACHE is dfcache type of task,
/// dfcache task is a cache task, and the task url is fake url.
/// It can only be used for caching and cannot be downloaded back to source.
Dfcache = 1,
/// DFSTORE is dfstore type of task,
/// dfstore task is a persistent task in backend.
Dfstore = 2,
/// STANDARD is standard type of task, it can download from source, remote peer and
/// local peer(local cache). When the standard task is never downloaded in the
/// P2P cluster, dfdaemon will download the task from the source. When the standard
/// task is downloaded in the P2P cluster, dfdaemon will download the task from
/// the remote peer or local peer(local cache).
Standard = 0,
/// PERSIST is persist type of task, it can import file and export file in P2P cluster.
/// When the persist task is imported into the P2P cluster, dfdaemon will store
/// the task in the peer's disk and copy multiple replicas to remote peers to
/// prevent data loss.
Persist = 1,
/// PERSIST_CACHE is persist cache type of task, it can import file and export file in P2P cluster.
/// When the persist cache task is imported into the P2P cluster, dfdaemon will store
/// the task in the peer's disk and copy multiple replicas to remote peers to prevent data loss.
/// When the expiration time is reached, task will be deleted in the P2P cluster.
PersistCache = 2,
}
impl TaskType {
/// String value of the enum field names used in the ProtoBuf definition.
Expand All @@ -592,17 +598,17 @@ impl TaskType {
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
TaskType::Dfdaemon => "DFDAEMON",
TaskType::Dfcache => "DFCACHE",
TaskType::Dfstore => "DFSTORE",
TaskType::Standard => "STANDARD",
TaskType::Persist => "PERSIST",
TaskType::PersistCache => "PERSIST_CACHE",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"DFDAEMON" => Some(Self::Dfdaemon),
"DFCACHE" => Some(Self::Dfcache),
"DFSTORE" => Some(Self::Dfstore),
"STANDARD" => Some(Self::Standard),
"PERSIST" => Some(Self::Persist),
"PERSIST_CACHE" => Some(Self::PersistCache),
_ => None,
}
}
Expand Down
Binary file modified src/descriptor.bin
Binary file not shown.
Loading