Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support get/cancel/remove tasks under specific condition given by a function #4

Merged
merged 1 commit into from
Oct 26, 2024

Conversation

KirCute
Copy link
Contributor

@KirCute KirCute commented Oct 25, 2024

昨天我在AList的主仓库下面提出了#7398这个issue,它是关于让GENERAL用户也能看到和控制由自己创建的离线下载/上传/复制任务的。今天我尝试了在尽可能不将需求侵入到这个库里的条件下实现这个需求,为此我在AList主项目中创建了一个新的Task结构体并内嵌了tache.Base结构体,在这个新的结构体中添加Creator成员。但是要实现从Manager中取出具有特定Creator的Task,就需要一个类似GetByState的GetByCreator函数(其实也可以先用GetAll得到所有Task,再从中筛选,但那样的话会多创建一个切片,有效率问题而且不够优雅)。因此我实现了GetByCondition、CancelByCondition、RemoveByCondition三个Manager的成员函数,它们可以根据由调用者给出的,匿名函数形式的条件,来得到/停止/删除部分Manager中的Task,这样以后所有基于此库开发,且有对Task进行扩展的需求的情况,就能用这三个接口实现依赖倒置。

@xhofe xhofe merged commit 1ed6bde into xhofe:main Oct 26, 2024
@KirCute KirCute deleted the feat/manager-get-by-condition branch October 26, 2024 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants