Documentation ¶
Index ¶
- func CreateConfig(writer io.Writer, workHome string) *config.Config
- func CreateRandomString(cap int) string
- func CreateTestFile(path string, content string) error
- func CreateTestFileWithMD5(path string, content string) string
- func GetServiceFile(taskFileName, dataDir string) string
- func GetTaskFile(taskFileName, dataDir string) string
- func GetTaskName(serviceFile string) string
- func IsCDN(pattern string) bool
- func IsP2P(pattern string) bool
- func IsSource(pattern string) bool
- type ClientErrorFuncType
- type MockSupernodeAPI
- func (m *MockSupernodeAPI) PullPieceTask(ip string, req *types.PullPieceTaskRequest) (*types.PullPieceTaskResponse, error)
- func (m *MockSupernodeAPI) Register(ip string, req *types.RegisterRequest) (*types.RegisterResponse, error)
- func (m *MockSupernodeAPI) ReportClientError(ip string, req *types.ClientErrorRequest) (resp *types.BaseResponse, e error)
- func (m *MockSupernodeAPI) ReportPiece(ip string, req *types.ReportPieceRequest) (*types.BaseResponse, error)
- func (m *MockSupernodeAPI) ServiceDown(ip string, taskID string, cid string) (*types.BaseResponse, error)
- type PullFuncType
- type RegisterFuncType
- type ReportFuncType
- type ServiceDownFuncType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateConfig ¶
CreateConfig create a temporary config
func CreateRandomString ¶
CreateRandomString create a random string of specified length.
func CreateTestFile ¶
CreateTestFile create a temp file and write a string.
func CreateTestFileWithMD5 ¶
CreateTestFileWithMD5 create a temp file and write a string and return the md5 of the file.
func GetServiceFile ¶
GetServiceFile returns file path of service file.
func GetTaskFile ¶
GetTaskFile returns file path of task file.
func GetTaskName ¶
GetTaskName extracts and returns task name from serviceFile.
Types ¶
type ClientErrorFuncType ¶ added in v0.3.1
type ClientErrorFuncType func(ip string, req *types.ClientErrorRequest) (*types.BaseResponse, error)
ClientErrorFuncType function type of SupernodeAPI#ReportClientError
type MockSupernodeAPI ¶
type MockSupernodeAPI struct { RegisterFunc RegisterFuncType PullFunc PullFuncType ReportFunc ReportFuncType ServiceDownFunc ServiceDownFuncType ClientErrorFunc ClientErrorFuncType }
MockSupernodeAPI mock SupernodeAPI
func (*MockSupernodeAPI) PullPieceTask ¶
func (m *MockSupernodeAPI) PullPieceTask(ip string, req *types.PullPieceTaskRequest) ( *types.PullPieceTaskResponse, error)
PullPieceTask implements SupernodeAPI#PullPiece
func (*MockSupernodeAPI) Register ¶
func (m *MockSupernodeAPI) Register(ip string, req *types.RegisterRequest) ( *types.RegisterResponse, error)
Register implements SupernodeAPI#Register
func (*MockSupernodeAPI) ReportClientError ¶ added in v0.3.1
func (m *MockSupernodeAPI) ReportClientError(ip string, req *types.ClientErrorRequest) (resp *types.BaseResponse, e error)
ReportClientError implements SupernodeAPI#ReportClientError
func (*MockSupernodeAPI) ReportPiece ¶
func (m *MockSupernodeAPI) ReportPiece(ip string, req *types.ReportPieceRequest) ( *types.BaseResponse, error)
ReportPiece implements SupernodeAPI#ReportPiece
func (*MockSupernodeAPI) ServiceDown ¶
func (m *MockSupernodeAPI) ServiceDown(ip string, taskID string, cid string) ( *types.BaseResponse, error)
ServiceDown implements SupernodeAPI#ServiceDown
type PullFuncType ¶
type PullFuncType func(ip string, req *types.PullPieceTaskRequest) (*types.PullPieceTaskResponse, error)
PullFuncType function type of SupernodeAPI#PullPiece
type RegisterFuncType ¶
type RegisterFuncType func(ip string, req *types.RegisterRequest) (*types.RegisterResponse, error)
RegisterFuncType function type of SupernodeAPI#Register
func CreateRegisterFunc ¶
func CreateRegisterFunc() RegisterFuncType
CreateRegisterFunc creates a mock register function
type ReportFuncType ¶
type ReportFuncType func(ip string, req *types.ReportPieceRequest) (*types.BaseResponse, error)
ReportFuncType function type of SupernodeAPI#ReportPiece
type ServiceDownFuncType ¶
ServiceDownFuncType function type of SupernodeAPI#ServiceDown