mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-12-12 13:15:09 +08:00
dd3654f953
Signed-off-by: bigsheeper <yihao.dai@zilliz.com>
43 lines
764 B
Go
43 lines
764 B
Go
package master
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/zilliztech/milvus-distributed/internal/errors"
|
|
"github.com/zilliztech/milvus-distributed/internal/proto/internalpb"
|
|
)
|
|
|
|
// TODO: get timestamp from timestampOracle
|
|
|
|
type baseTask struct {
|
|
sch *ddRequestScheduler
|
|
mt *metaTable
|
|
cv chan error
|
|
}
|
|
|
|
type task interface {
|
|
Type() internalpb.MsgType
|
|
Ts() (Timestamp, error)
|
|
Execute() error
|
|
WaitToFinish(ctx context.Context) error
|
|
Notify(err error)
|
|
}
|
|
|
|
func (bt *baseTask) Notify(err error) {
|
|
bt.cv <- err
|
|
}
|
|
|
|
func (bt *baseTask) WaitToFinish(ctx context.Context) error {
|
|
for {
|
|
select {
|
|
case <-ctx.Done():
|
|
return errors.Errorf("context done")
|
|
case err, ok := <-bt.cv:
|
|
if !ok {
|
|
return errors.Errorf("notify chan closed")
|
|
}
|
|
return err
|
|
}
|
|
}
|
|
}
|