mirror of https://github.com/milvus-io/milvus.git
enhance: using timer instead of ticker in client/index.go (#35552)
https://github.com/milvus-io/milvus/issues/35551 Signed-off-by: fengjun2016 <jornfeng@gmail.com>pull/35579/head
parent
b4743b4ca8
commit
795339ecbc
|
@ -39,11 +39,11 @@ type CreateIndexTask struct {
|
|||
}
|
||||
|
||||
func (t *CreateIndexTask) Await(ctx context.Context) error {
|
||||
ticker := time.NewTicker(t.interval)
|
||||
defer ticker.Stop()
|
||||
timer := time.NewTimer(t.interval)
|
||||
defer timer.Stop()
|
||||
for {
|
||||
select {
|
||||
case <-ticker.C:
|
||||
case <-timer.C:
|
||||
finished := false
|
||||
err := t.client.callService(func(milvusService milvuspb.MilvusServiceClient) error {
|
||||
resp, err := milvusService.DescribeIndex(ctx, &milvuspb.DescribeIndexRequest{
|
||||
|
@ -75,7 +75,7 @@ func (t *CreateIndexTask) Await(ctx context.Context) error {
|
|||
if finished {
|
||||
return nil
|
||||
}
|
||||
ticker.Reset(t.interval)
|
||||
timer.Reset(t.interval)
|
||||
case <-ctx.Done():
|
||||
return ctx.Err()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue