Skip to content

Commit

Permalink
feat: add current_replica_count and current_persistent_replica_count …
Browse files Browse the repository at this point in the history
…for PersistentCacheTask (#409)

Signed-off-by: Gaius <[email protected]>
  • Loading branch information
gaius-qi authored Oct 30, 2024
1 parent 8cbd523 commit 48131a6
Show file tree
Hide file tree
Showing 9 changed files with 442 additions and 420 deletions.
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.168"
version = "2.0.169"
authors = ["Gaius <[email protected]>"]
edition = "2021"
license = "Apache-2.0"
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module d7y.io/api/v2

go 1.21
go 1.23.0

require (
github.com/envoyproxy/protoc-gen-validate v1.1.0
Expand Down
758 changes: 387 additions & 371 deletions pkg/apis/common/v2/common.pb.go

Large diffs are not rendered by default.

13 changes: 3 additions & 10 deletions pkg/apis/common/v2/common.pb.validate.go

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

26 changes: 15 additions & 11 deletions pkg/apis/common/v2/common.proto
Original file line number Diff line number Diff line change
Expand Up @@ -213,27 +213,31 @@ message PersistentCacheTask {
// not be deleted when dfdamon runs garbage collection. It only be deleted
// when the task is deleted by the user.
uint64 persistent_replica_count = 2 [(validate.rules).uint64.gte = 1];
// Replica count of the cache task. If cache task is not persistent,
// Current replica count of the persistent cache task. The persistent cache task
// will not be deleted when dfdaemon runs garbage collection. It only be deleted
// when the task is deleted by the user.
uint64 current_persistent_replica_count = 3;
// Current replica count of the cache task. If cache task is not persistent,
// the persistent cache task will be deleted when dfdaemon runs garbage collection.
uint64 replica_count = 3 [(validate.rules).uint64.gte = 1];
uint64 current_replica_count = 4;
// Digest of the task digest, for example blake3:xxx or sha256:yyy.
string digest = 4 [(validate.rules).string = {pattern: "^(md5:[a-fA-F0-9]{32}|sha1:[a-fA-F0-9]{40}|sha256:[a-fA-F0-9]{64}|sha512:[a-fA-F0-9]{128}|blake3:[a-fA-F0-9]{64}|crc32:[a-fA-F0-9]{8})$"}];
string digest = 5 [(validate.rules).string = {pattern: "^(md5:[a-fA-F0-9]{32}|sha1:[a-fA-F0-9]{40}|sha256:[a-fA-F0-9]{64}|sha512:[a-fA-F0-9]{128}|blake3:[a-fA-F0-9]{64}|crc32:[a-fA-F0-9]{8})$"}];
// Tag is used to distinguish different persistent cache tasks.
optional string tag = 5;
optional string tag = 6;
// Application of task.
optional string application = 6;
optional string application = 7;
// Task piece length.
uint64 piece_length = 7 [(validate.rules).uint64.gte = 1];
uint64 piece_length = 8 [(validate.rules).uint64.gte = 1];
// Task content length.
uint64 content_length = 8;
uint64 content_length = 9;
// Task piece count.
uint32 piece_count = 9;
uint32 piece_count = 10;
// Task state.
string state = 10 [(validate.rules).string.min_len = 1];
string state = 11 [(validate.rules).string.min_len = 1];
// Task create time.
google.protobuf.Timestamp created_at = 11 [(validate.rules).timestamp.required = true];
google.protobuf.Timestamp created_at = 12 [(validate.rules).timestamp.required = true];
// Task update time.
google.protobuf.Timestamp updated_at = 12 [(validate.rules).timestamp.required = true];
google.protobuf.Timestamp updated_at = 13 [(validate.rules).timestamp.required = true];
}

// Host metadata.
Expand Down
28 changes: 16 additions & 12 deletions proto/common.proto
Original file line number Diff line number Diff line change
Expand Up @@ -207,29 +207,33 @@ message PersistentCacheTask {
// not be deleted when dfdamon runs garbage collection. It only be deleted
// when the task is deleted by the user.
uint64 persistent_replica_count = 2;
// Replica count of the cache task. If cache task is not persistent,
// Current replica count of the persistent cache task. The persistent cache task
// will not be deleted when dfdaemon runs garbage collection. It only be deleted
// when the task is deleted by the user.
uint64 current_persistent_replica_count = 3;
// Current replica count of the cache task. If cache task is not persistent,
// the persistent cache task will be deleted when dfdaemon runs garbage collection.
uint64 replica_count = 3;
uint64 current_replica_count = 4;
// Digest of the task digest, for example blake3:xxx or sha256:yyy.
string digest = 4;
string digest = 5;
// Tag is used to distinguish different persistent cache tasks.
optional string tag = 5;
optional string tag = 6;
// Application of task.
optional string application = 6;
optional string application = 7;
// Task piece length.
uint64 piece_length = 7;
uint64 piece_length = 8;
// Task content length.
uint64 content_length = 8;
uint64 content_length = 9;
// Task piece count.
uint32 piece_count = 9;
uint32 piece_count = 10;
// Task state.
string state = 10;
string state = 11;
// TTL of the persistent cache task.
google.protobuf.Duration ttl = 11;
google.protobuf.Duration ttl = 12;
// Task create time.
google.protobuf.Timestamp created_at = 12;
google.protobuf.Timestamp created_at = 13;
// Task update time.
google.protobuf.Timestamp updated_at = 13;
google.protobuf.Timestamp updated_at = 14;
}

// Host metadata.
Expand Down
31 changes: 18 additions & 13 deletions src/common.v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,39 +151,44 @@ pub struct PersistentCacheTask {
/// when the task is deleted by the user.
#[prost(uint64, tag = "2")]
pub persistent_replica_count: u64,
/// Replica count of the cache task. If cache task is not persistent,
/// the persistent cache task will be deleted when dfdaemon runs garbage collection.
/// Current replica count of the persistent cache task. The persistent cache task
/// will not be deleted when dfdaemon runs garbage collection. It only be deleted
/// when the task is deleted by the user.
#[prost(uint64, tag = "3")]
pub replica_count: u64,
pub current_persistent_replica_count: u64,
/// Current replica count of the cache task. If cache task is not persistent,
/// the persistent cache task will be deleted when dfdaemon runs garbage collection.
#[prost(uint64, tag = "4")]
pub current_replica_count: u64,
/// Digest of the task digest, for example blake3:xxx or sha256:yyy.
#[prost(string, tag = "4")]
#[prost(string, tag = "5")]
pub digest: ::prost::alloc::string::String,
/// Tag is used to distinguish different persistent cache tasks.
#[prost(string, optional, tag = "5")]
#[prost(string, optional, tag = "6")]
pub tag: ::core::option::Option<::prost::alloc::string::String>,
/// Application of task.
#[prost(string, optional, tag = "6")]
#[prost(string, optional, tag = "7")]
pub application: ::core::option::Option<::prost::alloc::string::String>,
/// Task piece length.
#[prost(uint64, tag = "7")]
#[prost(uint64, tag = "8")]
pub piece_length: u64,
/// Task content length.
#[prost(uint64, tag = "8")]
#[prost(uint64, tag = "9")]
pub content_length: u64,
/// Task piece count.
#[prost(uint32, tag = "9")]
#[prost(uint32, tag = "10")]
pub piece_count: u32,
/// Task state.
#[prost(string, tag = "10")]
#[prost(string, tag = "11")]
pub state: ::prost::alloc::string::String,
/// TTL of the persistent cache task.
#[prost(message, optional, tag = "11")]
#[prost(message, optional, tag = "12")]
pub ttl: ::core::option::Option<::prost_wkt_types::Duration>,
/// Task create time.
#[prost(message, optional, tag = "12")]
#[prost(message, optional, tag = "13")]
pub created_at: ::core::option::Option<::prost_wkt_types::Timestamp>,
/// Task update time.
#[prost(message, optional, tag = "13")]
#[prost(message, optional, tag = "14")]
pub updated_at: ::core::option::Option<::prost_wkt_types::Timestamp>,
}
/// Host metadata.
Expand Down
Binary file modified src/descriptor.bin
Binary file not shown.

0 comments on commit 48131a6

Please sign in to comment.