helper

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2019 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateConfig

func CreateConfig(writer io.Writer, workHome string) *config.Config

CreateConfig create a temporary config

func CreateRandomString

func CreateRandomString(cap int) string

CreateRandomString create a random string of specified length.

func CreateTestFile

func CreateTestFile(path string, content string) error

CreateTestFile create a temp file and write a string.

func CreateTestFileWithMD5

func CreateTestFileWithMD5(path string, content string) string

CreateTestFileWithMD5 create a temp file and write a string and return the md5 of the file.

func GetServiceFile

func GetServiceFile(taskFileName, dataDir string) string

GetServiceFile returns file path of service file.

func GetTaskFile

func GetTaskFile(taskFileName, dataDir string) string

GetTaskFile returns file path of task file.

func GetTaskName

func GetTaskName(serviceFile string) string

GetTaskName extracts and returns task name from serviceFile.

func IsCDN

func IsCDN(pattern string) bool

IsCDN returns whether the pattern is PatternCDN.

func IsP2P

func IsP2P(pattern string) bool

IsP2P returns whether the pattern is PatternP2P.

func IsSource

func IsSource(pattern string) bool

IsSource returns whether the pattern is PatternSource.

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

PullPieceTask implements SupernodeAPI#PullPiece

func (*MockSupernodeAPI) Register

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

type ServiceDownFuncType func(ip string, taskID string, cid string) (*types.BaseResponse, error)

ServiceDownFuncType function type of SupernodeAPI#ServiceDown

Jump to

Keyboard shortcuts

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