mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-15 12:53:41 +00:00
refactor: fetcher接口调整,返回channel来通知任务成功和失败
This commit is contained in:
1 parent
74d0e8e0bc
commit
79a93d5b50
5 files changed
+78
-66
No files matched your search
@@ -2,7 +2,7 @@ package base
|
||||
|
||||
// 对应协议的下载支持
|
||||
type Fetcher interface {
|
||||
Init(ctl Controller)
|
||||
Setup(ctl Controller) (err <-chan error)
|
||||
// 解析请求
|
||||
Resolve(req *Request) (res *Resource, err error)
|
||||
// 创建任务
|
||||
@@ -13,9 +13,12 @@ type Fetcher interface {
|
||||
}
|
||||
|
||||
type DefaultFetcher struct {
|
||||
Ctl Controller
|
||||
Ctl Controller
|
||||
DoneCh chan error
|
||||
}
|
||||
|
||||
func (f *DefaultFetcher) Init(ctl Controller) {
|
||||
func (f *DefaultFetcher) Setup(ctl Controller) (doneCh <-chan error) {
|
||||
f.Ctl = ctl
|
||||
f.DoneCh = make(chan error, 1)
|
||||
return f.DoneCh
|
||||
}
|
||||
Reference in new issue
Block a user