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 MockFileServer
- func (fs *MockFileServer) MockResp(resp http.ResponseWriter, mf *mockFile, rangeSt *httputils.RangeStruct)
- func (fs *MockFileServer) RegisterFile(path string, size int64, repeatStr string) error
- func (fs *MockFileServer) ServeHTTP(resp http.ResponseWriter, req *http.Request)
- func (fs *MockFileServer) StartServer(ctx context.Context, port int) error
- func (fs *MockFileServer) UnRegisterFile(path string)
- 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) ReportMetrics(ip string, req *api_types.TaskMetricsRequest) (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 ReportMetricsFuncType
- type ServiceDownFuncType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateConfig ¶
CreateConfig creates a temporary config.
func CreateRandomString ¶
CreateRandomString creates a random string of specified length.
func CreateTestFile ¶
CreateTestFile creates a temp file and write a string.
func CreateTestFileWithMD5 ¶
CreateTestFileWithMD5 creates 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 MockFileServer ¶ added in v1.0.1
MockFileServer mocks the file server.
func NewMockFileServer ¶ added in v1.0.1
func NewMockFileServer() *MockFileServer
func (*MockFileServer) MockResp ¶ added in v1.0.1
func (fs *MockFileServer) MockResp(resp http.ResponseWriter, mf *mockFile, rangeSt *httputils.RangeStruct)
func (*MockFileServer) RegisterFile ¶ added in v1.0.1
func (fs *MockFileServer) RegisterFile(path string, size int64, repeatStr string) error
func (*MockFileServer) ServeHTTP ¶ added in v1.0.1
func (fs *MockFileServer) ServeHTTP(resp http.ResponseWriter, req *http.Request)
func (*MockFileServer) StartServer ¶ added in v1.0.1
func (fs *MockFileServer) StartServer(ctx context.Context, port int) error
StartServer asynchronously starts the server, it will not be blocked.
func (*MockFileServer) UnRegisterFile ¶ added in v1.0.1
func (fs *MockFileServer) UnRegisterFile(path string)
type MockSupernodeAPI ¶
type MockSupernodeAPI struct { RegisterFunc RegisterFuncType PullFunc PullFuncType ReportFunc ReportFuncType ServiceDownFunc ServiceDownFuncType ClientErrorFunc ClientErrorFuncType ReportMetricsFunc ReportMetricsFuncType }
MockSupernodeAPI mocks the 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) ReportMetrics ¶ added in v1.0.0
func (m *MockSupernodeAPI) ReportMetrics(ip string, req *api_types.TaskMetricsRequest) (resp *types.BaseResponse, e error)
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 ReportMetricsFuncType ¶ added in v1.0.0
type ReportMetricsFuncType func(node string, req *api_types.TaskMetricsRequest) (*types.BaseResponse, error)
ClientErrorFuncType function type of SupernodeAPI#ReportMetricsType
type ServiceDownFuncType ¶
ServiceDownFuncType function type of SupernodeAPI#ServiceDown