Skip to content

Commit

Permalink
feat: add optional to peer message and piece message (#185)
Browse files Browse the repository at this point in the history
Signed-off-by: Gaius <[email protected]>
  • Loading branch information
gaius-qi authored Sep 21, 2023
1 parent f0928a3 commit f2e45a0
Show file tree
Hide file tree
Showing 7 changed files with 462 additions and 437 deletions.
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.27"
version = "2.0.28"
authors = ["Gaius <[email protected]>"]
edition = "2021"
license = "Apache-2.0"
Expand Down
719 changes: 364 additions & 355 deletions pkg/apis/common/v2/common.pb.go

Large diffs are not rendered by default.

142 changes: 79 additions & 63 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.

10 changes: 5 additions & 5 deletions pkg/apis/common/v2/common.proto
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ message Peer {
// Peer id.
string id = 1 [(validate.rules).string.min_len = 1];
// Range is url range of request.
Range range = 2;
optional Range range = 2;
// Peer priority.
Priority priority = 3 [(validate.rules).enum.defined_only = true];
// Pieces of peer.
Expand Down Expand Up @@ -141,11 +141,11 @@ message Task {
// Download url.
string url = 3 [(validate.rules).string.uri = true];
// Digest of the pieces digest, for example md5: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})$", ignore_empty: true}];
optional 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})$", ignore_empty: true}];
// URL tag identifies different task for same url.
string tag = 5;
optional string tag = 5;
// Application of task.
string application = 6;
optional string application = 6;
// Filter url used to generate task id.
repeated string filters = 7;
// Task request headers.
Expand Down Expand Up @@ -358,7 +358,7 @@ message Piece {
// Piece number.
int32 number = 1 [(validate.rules).int32.gte = 0];
// Parent peer id.
string parent_id = 2 [(validate.rules).string = {min_len: 1, ignore_empty: true}];
optional string parent_id = 2 [(validate.rules).string = {min_len: 1, ignore_empty: true}];
// Piece offset.
uint64 offset = 3 [(validate.rules).uint64.gte = 0];
// Piece length.
Expand Down
10 changes: 5 additions & 5 deletions proto/common.proto
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ message Peer {
// Peer id.
string id = 1;
// Range is url range of request.
Range range = 2;
optional Range range = 2;
// Peer priority.
Priority priority = 3;
// Pieces of peer.
Expand Down Expand Up @@ -135,11 +135,11 @@ message Task {
// Download url.
string url = 3;
// Digest of the pieces digest, for example md5:xxx or sha256:yyy.
string digest = 4;
optional string digest = 4;
// URL tag identifies different task for same url.
string tag = 5;
optional string tag = 5;
// Application of task.
string application = 6;
optional string application = 6;
// Filter url used to generate task id.
repeated string filters = 7;
// Task request headers.
Expand Down Expand Up @@ -352,7 +352,7 @@ message Piece {
// Piece number.
int32 number = 1;
// Parent peer id.
string parent_id = 2;
optional string parent_id = 2;
// Piece offset.
uint64 offset = 3;
// Piece length.
Expand Down
16 changes: 8 additions & 8 deletions src/common.v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ pub struct Task {
#[prost(string, tag = "3")]
pub url: ::prost::alloc::string::String,
/// Digest of the pieces digest, for example md5:xxx or sha256:yyy.
#[prost(string, tag = "4")]
pub digest: ::prost::alloc::string::String,
#[prost(string, optional, tag = "4")]
pub digest: ::core::option::Option<::prost::alloc::string::String>,
/// URL tag identifies different task for same url.
#[prost(string, tag = "5")]
pub tag: ::prost::alloc::string::String,
#[prost(string, optional, tag = "5")]
pub tag: ::core::option::Option<::prost::alloc::string::String>,
/// Application of task.
#[prost(string, tag = "6")]
pub application: ::prost::alloc::string::String,
#[prost(string, optional, tag = "6")]
pub application: ::core::option::Option<::prost::alloc::string::String>,
/// Filter url used to generate task id.
#[prost(string, repeated, tag = "7")]
pub filters: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
Expand Down Expand Up @@ -371,8 +371,8 @@ pub struct Piece {
#[prost(int32, tag = "1")]
pub number: i32,
/// Parent peer id.
#[prost(string, tag = "2")]
pub parent_id: ::prost::alloc::string::String,
#[prost(string, optional, tag = "2")]
pub parent_id: ::core::option::Option<::prost::alloc::string::String>,
/// Piece offset.
#[prost(uint64, tag = "3")]
pub offset: u64,
Expand Down
Binary file modified src/descriptor.bin
Binary file not shown.

0 comments on commit f2e45a0

Please sign in to comment.