milvus/internal/rootcoord/rename_collection_task.go
jaime 1dcd9eeb79
Support rename collection (#21693)
Signed-off-by: jaime <yun.zhang@zilliz.com>
2023-01-19 14:13:43 +08:00

28 lines
732 B
Go

package rootcoord
import (
"context"
"github.com/milvus-io/milvus-proto/go-api/commonpb"
"github.com/milvus-io/milvus-proto/go-api/milvuspb"
)
type renameCollectionTask struct {
baseTask
Req *milvuspb.RenameCollectionRequest
}
func (t *renameCollectionTask) Prepare(ctx context.Context) error {
if err := CheckMsgType(t.Req.GetBase().GetMsgType(), commonpb.MsgType_RenameCollection); err != nil {
return err
}
return nil
}
func (t *renameCollectionTask) Execute(ctx context.Context) error {
if err := t.core.ExpireMetaCache(ctx, []string{t.Req.GetOldName()}, InvalidCollectionID, t.GetTs()); err != nil {
return err
}
return t.core.meta.RenameCollection(ctx, t.Req.GetOldName(), t.Req.GetNewName(), t.GetTs())
}