feat: remove and clear task

This commit is contained in:
Noah Hsu
2022-07-31 21:21:54 +08:00
parent be452aafde
commit cb06d3a19a
5 changed files with 98 additions and 1 deletions

View File

@ -3,6 +3,7 @@ package task
import (
"context"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
)
@ -91,6 +92,10 @@ func (t *Task[K]) retry() {
t.run()
}
func (t *Task[K]) Done() bool {
return t.state == SUCCEEDED || t.state == CANCELED || t.state == ERRORED
}
func (t *Task[K]) Cancel() {
if t.state == SUCCEEDED || t.state == CANCELED {
return