Documentation ¶
Index ¶
- func EncodeResponse(rw http.ResponseWriter, statusCode int, data interface{}) error
- type PullPieceTaskResponseContinueData
- type RegisterResponseData
- type ResultInfo
- func NewResultInfo(code int, msg string, data interface{}) ResultInfo
- func NewResultInfoWithCode(code int) ResultInfo
- func NewResultInfoWithCodeData(code int, data interface{}) ResultInfo
- func NewResultInfoWithCodeError(code int, err error) ResultInfo
- func NewResultInfoWithCodeMsg(code int, msg string) ResultInfo
- func NewResultInfoWithError(err error) ResultInfo
- type Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EncodeResponse ¶
func EncodeResponse(rw http.ResponseWriter, statusCode int, data interface{}) error
EncodeResponse encodes response in json and sends it.
Types ¶
type PullPieceTaskResponseContinueData ¶ added in v0.4.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.
type RegisterResponseData ¶ added in v0.4.0
type RegisterResponseData struct { TaskID string `json:"taskId"` FileLength int64 `json:"fileLength"` PieceSize int32 `json:"pieceSize"` CDNSource string `json:"cdnSource"` // in seed pattern, if peer selected as seed, AsSeed sets true. AsSeed bool `json:"asSeed"` // in seed pattern, if as seed, SeedTaskID is the taskID of seed file. SeedTaskID string `json:"seedTaskID"` }
RegisterResponseData is the data when registering supernode successfully.
type ResultInfo ¶ added in v0.4.0
type ResultInfo struct {
// contains filtered or unexported fields
}
ResultInfo identify a struct that will be returned to the client.
func NewResultInfo ¶ added in v0.4.0
func NewResultInfo(code int, msg string, data interface{}) ResultInfo
NewResultInfo returns a new ResultInfo.
func NewResultInfoWithCode ¶ added in v0.4.0
func NewResultInfoWithCode(code int) ResultInfo
NewResultInfoWithCode returns a new ResultInfo with code and it will get the default msg corresponding to the code as the value of ResultInfo.msg.
func NewResultInfoWithCodeData ¶ added in v0.4.0
func NewResultInfoWithCodeData(code int, data interface{}) ResultInfo
NewResultInfoWithCodeData returns a new ResultInfo with code and specified data.
func NewResultInfoWithCodeError ¶ added in v0.4.0
func NewResultInfoWithCodeError(code int, err error) ResultInfo
NewResultInfoWithCodeError returns a new ResultInfo with code and error. And it will get the err.Error() as the value of ResultInfo.msg.
func NewResultInfoWithCodeMsg ¶ added in v0.4.0
func NewResultInfoWithCodeMsg(code int, msg string) ResultInfo
NewResultInfoWithCodeMsg returns a new ResultInfo with code and specified msg.
func NewResultInfoWithError ¶ added in v0.4.0
func NewResultInfoWithError(err error) ResultInfo
NewResultInfoWithError returns a new ResultInfo with error only. And it will fill the result code according to the type of error.
func (ResultInfo) Error ¶ added in v0.4.0
func (r ResultInfo) Error() string
func (ResultInfo) SuccessCode ¶ added in v0.4.0
func (r ResultInfo) SuccessCode() bool
SuccessCode returns whether the code equals SuccessCode.
type Server ¶
type Server struct { Config *config.Config PeerMgr mgr.PeerMgr TaskMgr mgr.TaskMgr DfgetTaskMgr mgr.DfgetTaskMgr ProgressMgr mgr.ProgressMgr GCMgr mgr.GCMgr PieceErrorMgr mgr.PieceErrorMgr PreheatMgr mgr.PreheatManager // contains filtered or unexported fields }
Server is supernode server struct.
func New ¶
func New(cfg *config.Config, logger *logrus.Logger, register prometheus.Registerer) (*Server, error)
New creates a brand new server instance.