Skip to content

Commit

Permalink
Remove redundant checks and add MetaCache (#301)
Browse files Browse the repository at this point in the history
Signed-off-by: zhenshan.cao <[email protected]>

Signed-off-by: zhenshan.cao <[email protected]>
  • Loading branch information
czs007 authored Aug 12, 2022
1 parent 1d91aa8 commit e83b1c1
Show file tree
Hide file tree
Showing 12 changed files with 252 additions and 326 deletions.
7 changes: 1 addition & 6 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,11 @@ import (
"time"

"github.com/milvus-io/milvus-sdk-go/v2/entity"

"google.golang.org/grpc"
)

// Client is the interface used to communicate with Milvus
// The common usage is like follow
// c, err := client.NewGrpcClient(context.Background, "address-to-milvus") // or other creation func maybe added later
// if err != nil {
// //handle err
// }
// // start doing things with client instance, note that there is no need to call Connect since NewXXXClient will do that for you
type Client interface {
// Close close the remaining connection resources
Close() error
Expand Down
16 changes: 14 additions & 2 deletions client/client_grpc_collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ import (

"github.com/golang/protobuf/proto"
"github.com/milvus-io/milvus-sdk-go/v2/entity"
"google.golang.org/grpc"

common "github.com/milvus-io/milvus-sdk-go/v2/internal/proto/common"
server "github.com/milvus-io/milvus-sdk-go/v2/internal/proto/server"
"google.golang.org/grpc"
)

// grpcClient, uses default grpc service definition to connect with Milvus2.0
Expand Down Expand Up @@ -231,6 +232,13 @@ func (c *grpcClient) DescribeCollection(ctx context.Context, collName string) (*
ConsistencyLevel: entity.ConsistencyLevel(resp.ConsistencyLevel),
}
collection.Name = collection.Schema.CollectionName
colInfo := collInfo{
ID: collection.ID,
Name: collection.Name,
Schema: collection.Schema,
ConsistencyLevel: collection.ConsistencyLevel,
}
MetaCache.setCollectionInfo(resp.CollectionName, &colInfo)
return collection, nil
}

Expand All @@ -250,7 +258,11 @@ func (c *grpcClient) DropCollection(ctx context.Context, collName string) error
if err != nil {
return err
}
return handleRespStatus(resp)
err = handleRespStatus(resp)
if err == nil {
MetaCache.setCollectionInfo(collName, nil)
}
return err
}

// HasCollection check whether collection name exists
Expand Down
Loading

0 comments on commit e83b1c1

Please sign in to comment.