Documentation
¶
Index ¶
- Constants
- func BuildIdentitySHA1(parts ...string) string
- func Cancel(ctx context.Context, taskID string) error
- func ClaimOrCreate(ctx context.Context, typ, identity, id string, totalBytes int64, data any) (taskID string, attached bool, err error)
- func Complete(ctx context.Context, taskID string) error
- func Fail(ctx context.Context, taskID string, errMsg string) error
- func Get(ctx context.Context, taskID string) (*model.Task, error)
- func Heartbeat(ctx context.Context, taskID string, hb HeartbeatData) (cancelRequested bool, err error)
- func ListRunning(ctx context.Context) ([]model.Task, error)
- func SetCanceled(ctx context.Context, taskID string) error
- type DownloadData
- type HeartbeatData
Constants ¶
View Source
const (
TaskTypeDownload = "下载"
)
Variables ¶
This section is empty.
Functions ¶
func BuildIdentitySHA1 ¶
BuildIdentitySHA1 根据输入片段生成幂等用的 identity。
func ClaimOrCreate ¶
func ClaimOrCreate(ctx context.Context, typ, identity, id string, totalBytes int64, data any) (taskID string, attached bool, err error)
ClaimOrCreate 尝试以 identity 附着到已有运行任务;若不存在或已陈旧则创建/接管。 attached==true 表示已存在活跃任务,调用方不应重复启动,而是提示用户查看状态。
Types ¶
type DownloadData ¶
Click to show internal directories.
Click to hide internal directories.