Documentation ¶
Index ¶
- Constants
- func IsEqual(task1, task2 SeedTask) bool
- func IsSame(task1, task2 *SeedTask) bool
- func IsTaskNotFound(err error) bool
- type Config
- type Manager
- type PieceInfo
- type SeedTask
- func (task *SeedTask) Clone() *SeedTask
- func (task *SeedTask) IsDone() bool
- func (task *SeedTask) IsError() bool
- func (task *SeedTask) IsFrozen() bool
- func (task *SeedTask) IsSuccess() bool
- func (task *SeedTask) IsWait() bool
- func (task *SeedTask) Log() *logger.SugaredLoggerOnWith
- func (task *SeedTask) StartTrigger()
- func (task *SeedTask) UpdateStatus(cdnStatus string)
- func (task *SeedTask) UpdateTaskInfo(cdnStatus, realDigest, pieceMd5Sign string, ...)
Constants ¶
View Source
const ( // DefaultGCInitialDelay is the delay time from the start to the first GC execution. DefaultGCInitialDelay = 6 * time.Second // DefaultGCMetaInterval is the interval time to execute the GC meta. DefaultGCMetaInterval = 2 * time.Minute // DefaultExpireTime when a task is not accessed within the ExpireTime, // and it will be treated to be expired. DefaultExpireTime = 30 * time.Minute )
gc config
View Source
const ( // StatusWaiting captures enum value "WAITING" StatusWaiting string = "WAITING" // StatusRunning captures enum value "RUNNING" StatusRunning string = "RUNNING" // StatusFailed captures enum value "FAILED" StatusFailed string = "FAILED" // StatusSuccess captures enum value "SUCCESS" StatusSuccess string = "SUCCESS" // StatusSourceError captures enum value "SOURCE_ERROR" StatusSourceError string = "SOURCE_ERROR" )
View Source
const ( // DefaultFailAccessInterval is the interval time after failed to access the URL. DefaultFailAccessInterval = 3 * time.Minute )
View Source
const (
UnknownTotalPieceCount = -1
)
Variables ¶
This section is empty.
Functions ¶
func IsTaskNotFound ¶ added in v2.0.2
Types ¶
type Config ¶ added in v2.0.2
type Config struct { // GCInitialDelay is the delay time from the start to the first GC execution. // default: 6s GCInitialDelay time.Duration `yaml:"gcInitialDelay" mapstructure:"gcInitialDelay"` // GCMetaInterval is the interval time to execute GC meta. // default: 2min GCMetaInterval time.Duration `yaml:"gcMetaInterval" mapstructure:"gcMetaInterval"` // ExpireTime when a task is not accessed within the ExpireTime, // and it will be treated to be expired. // default: 3min ExpireTime time.Duration `yaml:"taskExpireTime" mapstructure:"taskExpireTime"` // FailAccessInterval is the interval time after failed to access the URL. // unit: minutes // default: 30 FailAccessInterval time.Duration `yaml:"failAccessInterval" mapstructure:"failAccessInterval"` }
func DefaultConfig ¶ added in v2.0.2
func DefaultConfig() Config
type Manager ¶
type Manager interface { // AddOrUpdate update existing task info for the key if present. // Otherwise, it stores and returns the given value. // The isUpdate result is true if the value was updated, false if added. AddOrUpdate(registerTask *SeedTask) (seedTask *SeedTask, err error) // Get returns the task info with specified taskID, or nil if no // value is present. // The ok result indicates whether value was found in the taskManager. Get(taskID string) (seedTask *SeedTask, err error) // Update the task info with specified taskID and updateTask Update(taskID string, updateTask *SeedTask) (err error) // UpdateProgress update the downloaded pieces belonging to the task UpdateProgress(taskID string, piece *PieceInfo) (err error) // GetProgress returns the downloaded pieces belonging to the task GetProgress(taskID string) (map[uint32]*PieceInfo, error) // Exist check task existence with specified taskID. // returns the task info with specified taskID, or nil if no value is present. // The ok result indicates whether value was found in the taskManager. Exist(taskID string) (seedTask *SeedTask, ok bool) // Delete a task with specified taskID. Delete(taskID string) }
Manager as an interface defines all operations against SeedTask. A SeedTask will store some meta info about the taskFile, pieces and something else. A seedTask corresponds to three files on the disk, which are identified by taskId, the data file meta file piece file
func NewManager ¶
NewManager returns a new Manager Object.
type PieceInfo ¶ added in v2.0.2
type PieceInfo struct { PieceNum uint32 `json:"piece_num"` PieceMd5 string `json:"piece_md5"` PieceRange *rangeutils.Range `json:"piece_range"` OriginRange *rangeutils.Range `json:"origin_range"` PieceLen uint32 `json:"piece_len"` PieceStyle base.PieceStyle `json:"piece_style"` }
type SeedTask ¶ added in v2.0.2
type SeedTask struct { // ID of the task ID string `json:"ID,omitempty"` // RawURL is the resource's URL which user uses dfget to download. The location of URL can be anywhere, LAN or WAN. // For image distribution, this is image layer's URL in image registry. // The resource url is provided by dfget command line parameter. RawURL string `json:"rawURL,omitempty"` // TaskURL is generated from rawURL. rawURL may contain some queries or parameter, dfget will filter some queries via // --filter parameter of dfget. The usage of it is that different rawURL may generate the same taskID. TaskURL string `json:"taskURL,omitempty"` // SourceFileLength is the length of the source file in bytes. SourceFileLength int64 `json:"sourceFileLength,omitempty"` // CdnFileLength is the length of the file stored on CDN CdnFileLength int64 `json:"cdnFileLength,omitempty"` // PieceSize is the size of pieces in bytes PieceSize int32 `json:"pieceSize,omitempty"` // CdnStatus is the status of the created task related to CDN functionality. // // Enum: [WAITING RUNNING FAILED SUCCESS SOURCE_ERROR] CdnStatus string `json:"cdnStatus,omitempty"` // TotalPieceCount is the total number of pieces TotalPieceCount int32 `json:"totalPieceCount,omitempty"` // SourceRealDigest when CDN finishes downloading file/image from the source location, // the md5 sum of the source file will be calculated as the value of the SourceRealDigest. // And it will be used to compare with RequestDigest value to check whether file is complete. SourceRealDigest string `json:"sourceRealDigest,omitempty"` // PieceMd5Sign Is the SHA256 signature of all pieces md5 signature PieceMd5Sign string `json:"pieceMd5Sign,omitempty"` // Digest checks integrity of url content, for example md5:xxx or sha256:yyy Digest string `json:"digest,omitempty"` // Tag identifies different task for same url, conflict with digest Tag string `json:"tag,omitempty"` // Range content range for url Range string `json:"range,omitempty"` // Filter url used to generate task id Filter string `json:"filter,omitempty"` // Header other url header infos Header map[string]string `json:"header,omitempty"` // Pieces pieces of task Pieces map[uint32]*PieceInfo `json:"-"` // contains filtered or unexported fields }
func NewSeedTask ¶ added in v2.0.2
func (*SeedTask) IsSuccess ¶ added in v2.0.2
IsSuccess determines that whether the CDNStatus is success.
func (*SeedTask) Log ¶ added in v2.0.2
func (task *SeedTask) Log() *logger.SugaredLoggerOnWith
func (*SeedTask) StartTrigger ¶ added in v2.0.2
func (task *SeedTask) StartTrigger()
func (*SeedTask) UpdateStatus ¶ added in v2.0.2
func (*SeedTask) UpdateTaskInfo ¶ added in v2.0.2
Click to show internal directories.
Click to hide internal directories.