github.com/milvus-io/milvus-sdk-go/v2@v2.4.1/client/admin.go (about) 1 // Copyright (C) 2019-2021 Zilliz. All rights reserved. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance 4 // with the License. You may obtain a copy of the License at 5 // 6 // http://www.apache.org/licenses/LICENSE-2.0 7 // 8 // Unless required by applicable law or agreed to in writing, software distributed under the License 9 // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 10 // or implied. See the License for the specific language governing permissions and limitations under the License. 11 12 package client 13 14 import ( 15 "context" 16 17 "github.com/milvus-io/milvus-proto/go-api/v2/milvuspb" 18 "github.com/milvus-io/milvus-sdk-go/v2/entity" 19 ) 20 21 // GetVersion returns milvus server version information. 22 func (c *GrpcClient) GetVersion(ctx context.Context) (string, error) { 23 if c.Service == nil { 24 return "", ErrClientNotReady 25 } 26 resp, err := c.Service.GetVersion(ctx, &milvuspb.GetVersionRequest{}) 27 if err != nil { 28 return "", err 29 } 30 return resp.GetVersion(), nil 31 } 32 33 // CheckHealth returns milvus state 34 func (c *GrpcClient) CheckHealth(ctx context.Context) (*entity.MilvusState, error) { 35 if c.Service == nil { 36 return nil, ErrClientNotReady 37 } 38 resp, err := c.Service.CheckHealth(ctx, &milvuspb.CheckHealthRequest{}) 39 if err != nil { 40 return nil, err 41 } 42 43 states := make([]entity.QuotaState, 0, len(resp.GetQuotaStates())) 44 for _, state := range resp.GetQuotaStates() { 45 states = append(states, entity.QuotaState(state)) 46 } 47 48 return &entity.MilvusState{ 49 IsHealthy: resp.GetIsHealthy(), 50 Reasons: resp.GetReasons(), 51 QuotaStates: states, 52 }, nil 53 }