Skip to content

Commit

Permalink
enhance: enable setting properties during create database
Browse files Browse the repository at this point in the history
Signed-off-by: Wei Liu <[email protected]>
  • Loading branch information
weiliu1031 committed Jul 5, 2024
1 parent 6067806 commit f7f6dfa
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
12 changes: 12 additions & 0 deletions client/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,18 @@ type FlushOption func(*milvuspb.FlushRequest)

type CreateDatabaseOption func(*milvuspb.CreateDatabaseRequest)

func WithDatabaseProperty(key, value string) CreateDatabaseOption {
return func(req *milvuspb.CreateDatabaseRequest) {
if req.Properties == nil {
req.Properties = make([]*commonpb.KeyValuePair, 0)
}
req.Properties = append(req.Properties, &commonpb.KeyValuePair{
Key: key,
Value: value,
})
}
}

type DropDatabaseOption func(*milvuspb.DropDatabaseRequest)

type DescribeDatabaseOption func(*milvuspb.DescribeDatabaseRequest)
Expand Down
2 changes: 1 addition & 1 deletion examples/database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func main() {
clientDefault := mustConnect(ctx, cfg)
defer clientDefault.Close()
createCollection(ctx, clientDefault, "col1")
if err := clientDefault.CreateDatabase(ctx, "db1"); err != nil {
if err := clientDefault.CreateDatabase(ctx, "db1", client.WithDatabaseProperty("key1", "value1")); err != nil {
log.Fatalf("create db1 failed, %+v", err)
}
dbs, err := clientDefault.ListDatabases(ctx)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/go-faker/faker/v4 v4.1.0
github.com/golang/protobuf v1.5.2
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0
github.com/milvus-io/milvus-proto/go-api/v2 v2.4.3
github.com/milvus-io/milvus-proto/go-api/v2 v2.4.6-0.20240705061601-7a658711dc06
github.com/stretchr/testify v1.8.1
github.com/tidwall/gjson v1.14.4
github.com/x448/float16 v0.8.4
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ github.com/milvus-io/milvus-proto/go-api/v2 v2.3.4-0.20240430025921-135167be0694
github.com/milvus-io/milvus-proto/go-api/v2 v2.3.4-0.20240430025921-135167be0694/go.mod h1:1OIl0v5PQeNxIJhCvY+K55CBUOYDZevw9g9380u1Wek=
github.com/milvus-io/milvus-proto/go-api/v2 v2.4.3 h1:KUSaWVePVlHMIluAXf2qmNffI1CMlGFLLiP+4iy9014=
github.com/milvus-io/milvus-proto/go-api/v2 v2.4.3/go.mod h1:1OIl0v5PQeNxIJhCvY+K55CBUOYDZevw9g9380u1Wek=
github.com/milvus-io/milvus-proto/go-api/v2 v2.4.6-0.20240705061601-7a658711dc06 h1:b4ulIU5bNSxScgZ4eNb19Gdr6Xhv5pqaC2SOugFogao=
github.com/milvus-io/milvus-proto/go-api/v2 v2.4.6-0.20240705061601-7a658711dc06/go.mod h1:1OIl0v5PQeNxIJhCvY+K55CBUOYDZevw9g9380u1Wek=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
Expand Down

0 comments on commit f7f6dfa

Please sign in to comment.