Documentation
¶
Overview ¶
Package types defines all types of data send, received and stored. Do not use 'map[string]string' to define a data transported between different modules(systems). It's hard to read and maintain.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseResponse ¶
type BaseResponse struct {
// Code represents whether the response is successful.
Code int `json:"code"`
// Msg describes the detailed error message if the response is failed.
Msg string `json:"msg,omitempty"`
}
BaseResponse defines the common fields of responses from supernode. Types of supernode's responses could be defines as following:
type XXResponse struct {
*BaseResponse
Data *CustomizedDataStruct
}
func NewBaseResponse ¶
func NewBaseResponse(code int, msg string) *BaseResponse
NewBaseResponse create a BaseResponse instance.
func (*BaseResponse) IsSuccess ¶
func (res *BaseResponse) IsSuccess() bool
IsSuccess is used for determining whether the response is successful.
type ClientErrorRequest ¶ added in v0.3.1
type ClientErrorRequest struct {
ErrorType string `request:"errorType"`
SrcCid string `request:"srcCid"`
DstCid string `request:"dstCid"`
DstIP string `request:"dstIp"`
TaskID string `request:"taskId"`
Range string `request:"range"`
RealMd5 string `request:"realMd5"`
ExpectedMd5 string `request:"expectedMd5"`
}
ClientErrorRequest reports the error to supernode when dfget downloading piece from supernode
type PullPieceTaskRequest ¶
type PullPieceTaskRequest struct {
SrcCid string `request:"srcCid"`
DstCid string `request:"dstCid"`
Range string `request:"range"`
Result int `request:"result"`
Status int `request:"status"`
TaskID string `request:"taskId"`
}
PullPieceTaskRequest is send to supernodes when pulling pieces.
type PullPieceTaskResponse ¶ added in v0.3.0
type PullPieceTaskResponse struct {
*BaseResponse
Data json.RawMessage `json:"data,omitempty"`
// contains filtered or unexported fields
}
PullPieceTaskResponse is the response of PullPieceTaskRequest.
func (*PullPieceTaskResponse) ContinueData ¶ added in v0.3.0
func (res *PullPieceTaskResponse) ContinueData() []*PullPieceTaskResponseContinueData
ContinueData gets structured data from json.RawMessage when the task is continuing.
func (*PullPieceTaskResponse) FinishData ¶ added in v0.3.0
func (res *PullPieceTaskResponse) FinishData() *PullPieceTaskResponseFinishData
FinishData gets structured data from json.RawMessage when the task is finished.
func (*PullPieceTaskResponse) String ¶ added in v0.3.0
func (res *PullPieceTaskResponse) String() string
type PullPieceTaskResponseContinueData ¶ added in v0.3.0
type PullPieceTaskResponseContinueData struct {
Range string `json:"range"`
PieceNum int `json:"pieceNum"`
PieceSize int32 `json:"pieceSize"`
PieceMd5 string `json:"pieceMd5"`
Cid string `json:"cid"`
PeerIP string `json:"peerIp"`
PeerPort int `json:"peerPort"`
Path string `json:"path"`
DownLink int `json:"downLink"`
}
PullPieceTaskResponseContinueData is the data when successfully pulling piece task and the task is continuing.
func (*PullPieceTaskResponseContinueData) String ¶ added in v0.3.0
func (data *PullPieceTaskResponseContinueData) String() string
type PullPieceTaskResponseFinishData ¶ added in v0.3.0
type PullPieceTaskResponseFinishData struct {
Md5 string `json:"md5"`
FileLength int64 `json:"fileLength"`
}
PullPieceTaskResponseFinishData is the data when successfully pulling piece task and the task is finished.
func (*PullPieceTaskResponseFinishData) String ¶ added in v0.3.0
func (data *PullPieceTaskResponseFinishData) String() string
type RegisterRequest ¶
type RegisterRequest struct {
SupernodeIP string `json:"superNodeIp"`
RawURL string `json:"rawUrl"`
TaskURL string `json:"taskUrl"`
Cid string `json:"cid"`
IP string `json:"ip"`
HostName string `json:"hostName"`
Port int `json:"port"`
Path string `json:"path"`
Version string `json:"version,omitempty"`
Md5 string `json:"md5,omitempty"`
Identifier string `json:"identifier,omitempty"`
CallSystem string `json:"callSystem,omitempty"`
Headers []string `json:"headers,omitempty"`
Dfdaemon bool `json:"dfdaemon,omitempty"`
}
RegisterRequest contains all the parameters that need to be passed to the supernode when registering a downloading task.
func (*RegisterRequest) String ¶ added in v0.3.0
func (r *RegisterRequest) String() string
type RegisterResponse ¶
type RegisterResponse struct {
*BaseResponse
Data *RegisterResponseData `json:"data,omitempty"`
}
RegisterResponse is the response of register request.
func (*RegisterResponse) String ¶ added in v0.3.0
func (res *RegisterResponse) String() string
type RegisterResponseData ¶
type RegisterResponseData struct {
TaskID string `json:"taskId"`
FileLength int64 `json:"fileLength"`
PieceSize int32 `json:"pieceSize"`
}
RegisterResponseData is the data when registering supernode successfully.