api

package
v1.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 20, 2020 License: Apache-2.0 Imports: 15 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CheckServerRequest

type CheckServerRequest struct {
	TaskFileName string
	DataDir      string
	TotalLimit   int
}

CheckServerRequest wraps the request which is sent to uploader for check the peer server on port whether is available.

type DownloadAPI

type DownloadAPI interface {
	// Download downloads a piece and returns an HTTP response.
	Download(ip string, port int, req *DownloadRequest, timeout time.Duration) (*http.Response, error)
}

DownloadAPI defines the download method between dfget and peer server.

func NewDownloadAPI

func NewDownloadAPI() DownloadAPI

NewDownloadAPI returns a new DownloadAPI.

type DownloadRequest

type DownloadRequest struct {
	Path       string
	PieceRange string
	PieceNum   int
	PieceSize  int32
	Headers    map[string]string
}

DownloadRequest wraps the request which is sent to peer for downloading one piece.

type FinishTaskRequest

type FinishTaskRequest struct {
	TaskFileName string `request:"taskFileName"`
	TaskID       string `request:"taskID"`
	ClientID     string `request:"cid"`
	Node         string `request:"superNode"`
}

FinishTaskRequest wraps the request which is sent to uploader in order to report a finished task.

type ParseRateRequest

type ParseRateRequest struct {
	TaskFileName string
	RateLimit    int
}

ParseRateRequest wraps the request which is sent to uploader in order to calculate the rate limit dynamically.

type SupernodeAPI

type SupernodeAPI interface {
	Register(node string, req *types.RegisterRequest) (resp *types.RegisterResponse, e error)
	PullPieceTask(node string, req *types.PullPieceTaskRequest) (resp *types.PullPieceTaskResponse, e error)
	ReportPiece(node string, req *types.ReportPieceRequest) (resp *types.BaseResponse, e error)
	ServiceDown(node string, taskID string, cid string) (resp *types.BaseResponse, e error)
	ReportClientError(node string, req *types.ClientErrorRequest) (resp *types.BaseResponse, e error)
	ReportMetrics(node string, req *api_types.TaskMetricsRequest) (resp *types.BaseResponse, e error)
	HeartBeat(node string, req *api_types.HeartBeatRequest) (resp *types.HeartBeatResponse, err error)
	FetchP2PNetworkInfo(node string, start int, limit int, req *api_types.NetworkInfoFetchRequest) (resp *api_types.NetworkInfoFetchResponse, e error)
	ReportResource(node string, req *types.RegisterRequest) (resp *types.RegisterResponse, err error)
	ApplyForSeedNode(node string, req *types.RegisterRequest) (resp *types.RegisterResponse, err error)
	ReportResourceDeleted(node string, taskID string, cid string) (resp *types.BaseResponse, err error)
}

SupernodeAPI defines the communication methods between supernode and dfget.

func NewSupernodeAPI

func NewSupernodeAPI() SupernodeAPI

NewSupernodeAPI creates a new instance of SupernodeAPI with default value.

type UploaderAPI

type UploaderAPI interface {
	// ParseRate sends a request to uploader to calculate the rateLimit dynamically
	// for the speed limit of the whole host machine.
	ParseRate(ip string, port int, req *ParseRateRequest) (string, error)

	// CheckServer checks the peer server on port whether is available.
	CheckServer(ip string, port int, req *CheckServerRequest) (string, error)

	// FinishTask report a finished task to peer server.
	FinishTask(ip string, port int, req *FinishTaskRequest) error

	// PingServer send a request to determine whether the server has started.
	PingServer(ip string, port int) bool
}

UploaderAPI defines the communication methods between dfget and uploader.

func NewUploaderAPI

func NewUploaderAPI(timeout time.Duration) UploaderAPI

NewUploaderAPI returns a new UploaderAPI.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL