Close
この操作は、クライアントの gRPC 接続を閉じ、そのリソースを解放します。クライアントが不要になったとき、通常は defer を介して呼び出してください。
go
func (c *Client) Close(ctx context.Context) error
リクエスト構文
Close() のリクエストを作成します。
go
func (c *Client) Close(ctx context.Context) error
```
**PARAMETERS:**
- **ctx** (*context.Context*)
The context for the closing operation. The context is used for cancellation and deadlines.
**RETURN TYPE:**
*error*
**RETURNS:**
Returns nil on success, or an error if the underlying connection failed to close.
**EXCEPTIONS:**
- **error**
Check `err != nil` for failure details.
パラメーター:
-
ctx(context.Context) -
終了操作のコンテキストです。コンテキストは、キャンセルとデッドラインに使用されます。
戻り値の型:
error
戻り値:
成功した場合は nil を返し、基になる接続を閉じることに失敗した場合はエラーを返します。
エラー処理:
-
error
操作が失敗します。失敗の詳細については、
err != nilを確認してください。
例
Close() の使用方法を示します。
go
import (
"context"
"github.com/milvus-io/milvus/client/v3/milvusclient"
)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
cli, err := milvusclient.New(ctx, &milvusclient.ClientConfig{
Address: milvusAddr,
})
if err != nil {
// handle error
}
defer cli.Close(ctx)