Repository: milvus-io/milvus-sdk-go
Pull request #129 (2021-07-12 09:49:15)

Unify client param signature
Unify client parameter to pointer

Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>

sre-ci-robot: [APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *<a href="https://github.com/milvus-io/milvus-sdk-go/pull/129#" title="Author self-approved">congqixia</a>*

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=milvus-io%2Fmilvus-sdk-go).

The pull request process is described [here](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process)

<details >
Needs approval from an approver in each of these files:

- ~~[OWNERS](https://github.com/milvus-io/milvus-sdk-go/blob/master/OWNERS)~~ [congqixia]

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":[]} -->
sunby: /lgtm
/approve

sre-ci-robot: [APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *<a href="https://github.com/milvus-io/milvus-sdk-go/pull/129#" title="Author self-approved">congqixia</a>*, *<a href="https://github.com/milvus-io/milvus-sdk-go/pull/129#issuecomment-878137427" title="Approved">sunby</a>*

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=milvus-io%2Fmilvus-sdk-go).

The pull request process is described [here](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process)

<details >
Needs approval from an approver in each of these files:

- ~~[OWNERS](https://github.com/milvus-io/milvus-sdk-go/blob/master/OWNERS)~~ [congqixia,sunby]

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":[]} -->

Patch:
diff --git a/README.md b/README.md
index 906f5fc..6c8f311 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,11 @@
-## Milvus Go SDK
+# Milvus Go SDK
+
+[![license](https://img.shields.io/hexpm/l/plug.svg?color=green)](https://github.com/milvus-io/milvus-sdk-go/blob/master/LICENSE)
+[![Mergify Status][mergify-status]][mergify]
+
+[mergify]: https://mergify.io
+[mergify-status]: https://img.shields.io/endpoint.svg?url=https://gh.mergify.io/badges/milvus-io/milvus-sdk-go&style=plastic
+
 
 Go SDK for [Milvus](https://github.com/milvus-io/milvus). To contribute code to this project, please read our [contribution guidelines](https://github.com/milvus-io/milvus/blob/master/CONTRIBUTING.md) first.
 
diff --git a/client/client.go b/client/client.go
index 9e19a5b..ee81933 100644
--- a/client/client.go
+++ b/client/client.go
@@ -31,7 +31,7 @@ type Client interface {
 	// ListCollections list collections from connection
 	ListCollections(ctx context.Context) ([]*entity.Collection, error)
 	// CreateCollection create collection using provided schema
-	CreateCollection(ctx context.Context, schema entity.Schema, shardsNum int32) error
+	CreateCollection(ctx context.Context, schema *entity.Schema, shardsNum int32) error
 	// DescribeCollection describe collection meta
 	DescribeCollection(ctx context.Context, collName string) (*entity.Collection, error)
 	// DropCollection drop the specified collection
diff --git a/client/client_grpc_dd.go b/client/client_grpc_dd.go
index 5ae17cc..1122f40 100644
--- a/client/client_grpc_dd.go
+++ b/client/client_grpc_dd.go
@@ -127,7 +127,7 @@ func (c *grpcClient) ListCollections(ctx context.Context) ([]*entity.Collection,
 }
 
 // CreateCollection create collection with specified schema
-func (c *grpcClient) CreateCollection(ctx context.Context, collSchema entity.Schema, shardNum int32) error {
+func (c *grpcClient) CreateCollection(ctx context.Context, collSchema *entity.Schema, shardNum int32) error {
 	if c.service == nil {
 		return ErrClientNotReady
 	}
@@ -156,7 +156,10 @@ func (c *grpcClient) CreateCollection(ctx context.Context, collSchema entity.Sch
 	return nil
 }
 
-func validateSchema(sch entity.Schema) error {
+func validateSchema(sch *entity.Schema) error {
+	if sch == nil {
+		return errors.New("nil schema")
+	}
 	if sch.CollectionName == "" {
 		return errors.New("collection name cannot be empty")
 	}


Test patch:
diff --git a/client/client_grpc_dd_test.go b/client/client_grpc_dd_test.go
index ada3bcb..b7d33ea 100644
--- a/client/client_grpc_dd_test.go
+++ b/client/client_grpc_dd_test.go
@@ -201,7 +201,7 @@ func TestGrpcClientCreateCollection(t *testing.T) {
 	})
 
 	t.Run("Test invalid schemas", func(t *testing.T) {
-		cases := []entity.Schema{
+		cases := []*entity.Schema{
 			// empty fields
 			{
 				CollectionName: testCollectionName,
diff --git a/client/client_mock_test.go b/client/client_mock_test.go
index 2e48be7..55aff7d 100644
--- a/client/client_mock_test.go
+++ b/client/client_mock_test.go
@@ -71,8 +71,8 @@ const (
 	testVectorDim      = 128
 )
 
-func defaultSchema() entity.Schema {
-	return entity.Schema{
+func defaultSchema() *entity.Schema {
+	return &entity.Schema{
 		CollectionName: testCollectionName,
 		AutoID:         false,
 		Fields: []*entity.Field{