Skip to content
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.2.13"
version = "2.2.14"
authors = ["Gaius <gaius.qi@gmail.com>"]
edition = "2021"
license = "Apache-2.0"
Expand Down
13 changes: 6 additions & 7 deletions pkg/apis/cdnsystem/v1/cdnsystem.proto
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ import "validate/validate.proto";

option go_package = "d7y.io/api/v2/pkg/apis/cdnsystem/v1;cdnsystem";

message SeedRequest{
message SeedRequest {
string task_id = 1 [(validate.rules).string.min_len = 1];
string url = 2 [(validate.rules).string.uri = true];
common.UrlMeta url_meta = 3;
}

// keep piece meta and data separately
// check piece md5, md5s sign and total content length
message PieceSeed{
message PieceSeed {
// reuse already downloaded peer
bool reuse = 1;
// peer id for cdn node, need suffix with _CDN
Expand All @@ -55,12 +55,11 @@ message PieceSeed{
}

// CDN System RPC Service
service Seeder{
service Seeder {
// Generate seeds and return to scheduler
rpc ObtainSeeds(SeedRequest)returns(stream PieceSeed);
rpc ObtainSeeds(SeedRequest) returns (stream PieceSeed);
// Get piece tasks from cdn
rpc GetPieceTasks(common.PieceTaskRequest)returns(common.PiecePacket);
rpc GetPieceTasks(common.PieceTaskRequest) returns (common.PiecePacket);
// Sync piece tasks with other peers
rpc SyncPieceTasks(stream common.PieceTaskRequest)returns(stream common.PiecePacket);
rpc SyncPieceTasks(stream common.PieceTaskRequest) returns (stream common.PiecePacket);
}

51 changes: 36 additions & 15 deletions pkg/apis/common/v1/common.proto
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,17 @@ enum SizeScope {

// TaskType represents type of task.
enum TaskType {
// Normal is normal type of task,
// normal task is a normal p2p task.
// Normal is normal type of task,
// normal task is a normal p2p task.
Normal = 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 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 is dfstore type of task,
// dfstore task is a persistent task in backend.
DfStore = 2;
}

Expand Down Expand Up @@ -163,11 +163,17 @@ message GrpcDfError {
// UrlMeta describes url meta info.
message UrlMeta {
// Digest checks integrity of url content, for example md5:xxx or sha256:yyy.
string digest = 1 [(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}];
string digest = 1 [(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, conflict with digest.
string tag = 2;
// Content range for url.
string range = 3 [(validate.rules).string = {pattern: "^[0-9]+-[0-9]*$", ignore_empty:true}];
string range = 3 [(validate.rules).string = {
pattern: "^[0-9]+-[0-9]*$"
ignore_empty: true
}];
// Filter url used to generate task id.
string filter = 4;
// Other url header infos.
Expand Down Expand Up @@ -195,14 +201,17 @@ message PieceInfo {
int32 piece_num = 1;
uint64 range_start = 2 [(validate.rules).uint64.gte = 0];
uint32 range_size = 3 [(validate.rules).uint32.gte = 0];
string piece_md5 = 4 [(validate.rules).string = {pattern:"([a-f\\d]{32}|[A-F\\d]{32}|[a-f\\d]{16}|[A-F\\d]{16})", ignore_empty:true}];
string piece_md5 = 4 [(validate.rules).string = {
pattern: "([a-f\\d]{32}|[A-F\\d]{32}|[a-f\\d]{16}|[A-F\\d]{16})"
ignore_empty: true
}];
uint64 piece_offset = 5 [(validate.rules).uint64.gte = 0];
PieceStyle piece_style = 6;
// Cost of the downloading.
uint64 download_cost = 7 [(validate.rules).uint64.gte = 0];
}

// ExtendAttribute is extend attribute.
// ExtendAttribute is extend attribute.
message ExtendAttribute {
// Task response header, eg: HTTP Response Header.
map<string, string> header = 1;
Expand Down Expand Up @@ -238,13 +247,25 @@ message Host {
// Peer hostname.
string hostname = 3 [(validate.rules).string.hostname = true];
// Port of grpc service.
int32 port = 4 [(validate.rules).int32 = {gte: 1024, lt: 65535}];
int32 port = 4 [(validate.rules).int32 = {
gte: 1024
lt: 65535
}];
// Port of download server.
int32 download_port = 5 [(validate.rules).int32 = {gte: 1024, lt: 65535}];
int32 download_port = 5 [(validate.rules).int32 = {
gte: 1024
lt: 65535
}];
// Host location, eg: area|country|province|city.
string location = 7 [(validate.rules).string = {min_len: 1, ignore_empty: true}];
string location = 7 [(validate.rules).string = {
min_len: 1
ignore_empty: true
}];
// IDC where the peer host is located.
string idc = 8 [(validate.rules).string = {min_len: 1, ignore_empty: true}];
string idc = 8 [(validate.rules).string = {
min_len: 1
ignore_empty: true
}];
// Port of proxy server.
int32 proxy_port = 9;
}
8 changes: 4 additions & 4 deletions pkg/apis/dfdaemon/v1/dfdaemon.pb.go

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

38 changes: 19 additions & 19 deletions pkg/apis/dfdaemon/v1/dfdaemon.proto
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ syntax = "proto3";

package dfdaemon;

import "pkg/apis/common/v1/common.proto";
import "google/protobuf/empty.proto";
import "pkg/apis/common/v1/common.proto";
import "validate/validate.proto";

option go_package = "d7y.io/api/v2/pkg/apis/dfdaemon/v1;dfdaemon";

message DownRequest{
message DownRequest {
// Identify one downloading, the framework will fill it automatically.
// Deprecated
string uuid = 1;
Expand All @@ -51,7 +51,7 @@ message DownRequest{
bool recursive = 13;
}

message DownResult{
message DownResult {
// Task id.
string task_id = 2 [(validate.rules).string.min_len = 1];
// Peer id.
Expand All @@ -64,7 +64,7 @@ message DownResult{
string output = 6;
}

message StatTaskRequest{
message StatTaskRequest {
// Download url.
string url = 1 [(validate.rules).string.min_len = 1];
// URL meta info.
Expand All @@ -73,7 +73,7 @@ message StatTaskRequest{
bool local_only = 3;
}

message ImportTaskRequest{
message ImportTaskRequest {
// Download url.
string url = 1 [(validate.rules).string.min_len = 1];
// URL meta info.
Expand All @@ -84,7 +84,7 @@ message ImportTaskRequest{
common.TaskType type = 4;
}

message ExportTaskRequest{
message ExportTaskRequest {
// Download url.
string url = 1 [(validate.rules).string.min_len = 1];
// Output path of downloaded file.
Expand All @@ -103,7 +103,7 @@ message ExportTaskRequest{
bool local_only = 9;
}

message DeleteTaskRequest{
message DeleteTaskRequest {
// Download url.
string url = 1 [(validate.rules).string.min_len = 1];
// URL meta info.
Expand All @@ -128,29 +128,29 @@ message PeerMetadata {

// PeerExchangeData represents metadata of peer tasks.
message PeerExchangeData {
repeated PeerMetadata PeerMetadatas= 1;
repeated PeerMetadata PeerMetadatas = 1;
}

// Daemon Client RPC Service
service Daemon{
service Daemon {
// Trigger client to download file
rpc Download(DownRequest) returns(stream DownResult);
rpc Download(DownRequest) returns (stream DownResult);
// Get piece tasks from other peers
rpc GetPieceTasks(common.PieceTaskRequest)returns(common.PiecePacket);
rpc GetPieceTasks(common.PieceTaskRequest) returns (common.PiecePacket);
// Check daemon health
rpc CheckHealth(google.protobuf.Empty)returns(google.protobuf.Empty);
rpc CheckHealth(google.protobuf.Empty) returns (google.protobuf.Empty);
// Sync piece tasks with other peers
rpc SyncPieceTasks(stream common.PieceTaskRequest)returns(stream common.PiecePacket);
rpc SyncPieceTasks(stream common.PieceTaskRequest) returns (stream common.PiecePacket);
// Check if given task exists in P2P cache system
rpc StatTask(StatTaskRequest) returns(google.protobuf.Empty);
rpc StatTask(StatTaskRequest) returns (google.protobuf.Empty);
// Import the given file into P2P cache system
rpc ImportTask(ImportTaskRequest) returns(google.protobuf.Empty);
rpc ImportTask(ImportTaskRequest) returns (google.protobuf.Empty);
// Export or download file from P2P cache system
rpc ExportTask(ExportTaskRequest) returns(google.protobuf.Empty);
rpc ExportTask(ExportTaskRequest) returns (google.protobuf.Empty);
// Delete file from P2P cache system
rpc DeleteTask(DeleteTaskRequest) returns(google.protobuf.Empty);
rpc DeleteTask(DeleteTaskRequest) returns (google.protobuf.Empty);
// LeaveHost releases host in scheduler.
rpc LeaveHost(google.protobuf.Empty)returns(google.protobuf.Empty);
rpc LeaveHost(google.protobuf.Empty) returns (google.protobuf.Empty);
// Exchange peers between daemons
rpc PeerExchange(stream PeerExchangeData)returns(stream PeerExchangeData);
rpc PeerExchange(stream PeerExchangeData) returns (stream PeerExchangeData);
}
20 changes: 10 additions & 10 deletions pkg/apis/dfdaemon/v2/dfdaemon.pb.go

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

Loading