mirror of https://github.com/milvus-io/milvus.git
Add comment and implementation assertion for proxy condition.go (#9576)
Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>pull/9599/head
parent
02dc2a2453
commit
af1402dcb8
|
@ -23,11 +23,16 @@ type Condition interface {
|
|||
Ctx() context.Context
|
||||
}
|
||||
|
||||
// make sure interface implementation
|
||||
var _ Condition = (*TaskCondition)(nil)
|
||||
|
||||
// TaskCondition implements Condition interface for tasks
|
||||
type TaskCondition struct {
|
||||
done chan error
|
||||
ctx context.Context
|
||||
}
|
||||
|
||||
// WaitToFinish waits until the TaskCondition is notified or context done or canceled
|
||||
func (tc *TaskCondition) WaitToFinish() error {
|
||||
for {
|
||||
select {
|
||||
|
@ -39,14 +44,17 @@ func (tc *TaskCondition) WaitToFinish() error {
|
|||
}
|
||||
}
|
||||
|
||||
// Notify sends a signal into the done channel
|
||||
func (tc *TaskCondition) Notify(err error) {
|
||||
tc.done <- err
|
||||
}
|
||||
|
||||
// Ctx returns internal context
|
||||
func (tc *TaskCondition) Ctx() context.Context {
|
||||
return tc.ctx
|
||||
}
|
||||
|
||||
// NewTaskCondition creates a TaskCondition with provided context
|
||||
func NewTaskCondition(ctx context.Context) *TaskCondition {
|
||||
return &TaskCondition{
|
||||
done: make(chan error, 1),
|
||||
|
|
Loading…
Reference in New Issue