dragonfly/pkg/rpc/base/base.proto

136 lines
3.5 KiB
Protocol Buffer

/*
* Copyright 2020 The Dragonfly Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
syntax = "proto3";
package base;
option go_package = "d7y.io/dragonfly/v2/pkg/rpc/base";
enum Code{
X_UNSPECIFIED = 0;
// success code 200-299
Success = 200;
// framework can not find server node
ServerUnavailable = 500;
// common response error 1000-1999
// client can be migrated to another scheduler/CDN
ResourceLacked = 1000;
BadRequest = 1400;
PeerTaskNotFound = 1404;
UnknownError = 1500;
RequestTimeOut = 1504;
// client response error 4000-4999
ClientError = 4000;
ClientPieceRequestFail = 4001; // get piece task from other peer error
ClientScheduleTimeout = 4002; // wait scheduler response timeout
ClientContextCanceled = 4003;
ClientWaitPieceReady = 4004; // when target peer downloads from source slowly, should wait
ClientPieceDownloadFail = 4005;
ClientRequestLimitFail = 4006;
// scheduler response error 5000-5999
SchedError = 5000;
SchedNeedBackSource = 5001; // client should try to download from source
SchedPeerGone = 5002; // client should disconnect from scheduler
SchedPeerNotFound = 5004; // peer not found in scheduler
SchedPeerPieceResultReportFail = 5005; // report piece
SchedTaskStatusError = 5006; // task status is fail
// cdnsystem response error 6000-6999
CDNError = 6000;
CDNTaskRegistryFail = 6001;
CDNTaskDownloadFail = 6002;
CDNTaskNotFound = 6404;
// manager response error 7000-7999
InvalidResourceType = 7001;
}
enum PieceStyle{
PLAIN = 0;
}
enum SizeScope{
// size > one piece size
NORMAL = 0;
// 128 byte < size <= one piece size and be plain type
SMALL = 1;
// size <= 128 byte and be plain type
TINY = 2;
}
message GrpcDfError {
Code code = 1;
string message = 2;
}
// UrlMeta describes url meta info.
message UrlMeta{
// digest checks integrity of url content, for example md5:xxx or sha256:yyy
string digest = 1;
// url tag identifies different task for same url, conflict with digest
string tag = 2;
// content range for url
string range = 3;
// filter url used to generate task id
string filter = 4;
// other url header infos
map<string, string> header = 5;
}
message HostLoad{
// cpu usage
float cpu_ratio = 1;
// memory usage
float mem_ratio = 2;
// disk space usage
float disk_ratio = 3;
}
message PieceTaskRequest{
string task_id = 1;
string src_pid = 2;
string dst_pid = 3;
// piece number
int32 start_num = 4;
// expected piece count
int32 limit = 5;
}
message PieceInfo{
int32 piece_num = 1;
uint64 range_start = 2;
int32 range_size = 3;
string piece_md5 = 4;
uint64 piece_offset = 5;
base.PieceStyle piece_style = 6;
}
message PiecePacket{
string task_id = 2;
string dst_pid = 3;
// ip:port
string dst_addr = 4;
repeated PieceInfo piece_infos = 5;
// total piece count for url
int32 total_piece = 6;
int64 content_length = 7;
// sha256 code of all piece md5
string piece_md5_sign = 8;
}