2021-10-22 14:13:42 +08:00
|
|
|
// Licensed to the LF AI & Data foundation under one
|
|
|
|
// or more contributor license agreements. See the NOTICE file
|
|
|
|
// distributed with this work for additional information
|
|
|
|
// regarding copyright ownership. The ASF licenses this file
|
|
|
|
// to you under the Apache License, Version 2.0 (the
|
|
|
|
// "License"); you may not use this file except in compliance
|
2021-04-19 11:12:56 +08:00
|
|
|
// with the License. You may obtain a copy of the License at
|
|
|
|
//
|
2021-10-22 14:13:42 +08:00
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
2021-04-19 11:12:56 +08:00
|
|
|
//
|
2021-10-22 14:13:42 +08:00
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
2021-04-19 11:12:56 +08:00
|
|
|
|
2021-06-18 21:30:08 +08:00
|
|
|
package grpcrootcoordclient
|
2021-01-19 14:44:03 +08:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2021-05-24 09:44:49 +08:00
|
|
|
"fmt"
|
2021-01-19 14:44:03 +08:00
|
|
|
|
2023-09-21 09:45:27 +08:00
|
|
|
"go.uber.org/zap"
|
|
|
|
"google.golang.org/grpc"
|
|
|
|
grpcCodes "google.golang.org/grpc/codes"
|
|
|
|
grpcStatus "google.golang.org/grpc/status"
|
|
|
|
|
2023-06-09 01:28:37 +08:00
|
|
|
"github.com/milvus-io/milvus-proto/go-api/v2/commonpb"
|
|
|
|
"github.com/milvus-io/milvus-proto/go-api/v2/milvuspb"
|
2021-04-22 14:45:57 +08:00
|
|
|
"github.com/milvus-io/milvus/internal/proto/internalpb"
|
2021-06-17 17:45:56 +08:00
|
|
|
"github.com/milvus-io/milvus/internal/proto/proxypb"
|
2021-06-22 16:14:09 +08:00
|
|
|
"github.com/milvus-io/milvus/internal/proto/rootcoordpb"
|
2024-02-23 10:26:53 +08:00
|
|
|
"github.com/milvus-io/milvus/internal/types"
|
2021-12-03 15:15:32 +08:00
|
|
|
"github.com/milvus-io/milvus/internal/util/grpcclient"
|
2021-05-24 09:44:49 +08:00
|
|
|
"github.com/milvus-io/milvus/internal/util/sessionutil"
|
2023-04-06 19:14:32 +08:00
|
|
|
"github.com/milvus-io/milvus/pkg/log"
|
|
|
|
"github.com/milvus-io/milvus/pkg/util/commonpbutil"
|
|
|
|
"github.com/milvus-io/milvus/pkg/util/funcutil"
|
|
|
|
"github.com/milvus-io/milvus/pkg/util/paramtable"
|
|
|
|
"github.com/milvus-io/milvus/pkg/util/typeutil"
|
2021-01-19 14:44:03 +08:00
|
|
|
)
|
|
|
|
|
2022-11-04 14:25:38 +08:00
|
|
|
var Params *paramtable.ComponentParam = paramtable.Get()
|
2022-10-24 23:43:30 +08:00
|
|
|
|
2021-12-03 15:15:32 +08:00
|
|
|
// Client grpc client
|
|
|
|
type Client struct {
|
2022-10-17 20:05:26 +08:00
|
|
|
grpcClient grpcclient.GrpcClient[rootcoordpb.RootCoordClient]
|
2021-12-03 15:15:32 +08:00
|
|
|
sess *sessionutil.Session
|
2021-01-19 14:44:03 +08:00
|
|
|
}
|
|
|
|
|
2022-04-27 19:51:46 +08:00
|
|
|
// NewClient create root coordinator client with specified etcd info and timeout
|
2021-06-16 18:35:59 +08:00
|
|
|
// ctx execution control context
|
2021-06-17 16:47:57 +08:00
|
|
|
// metaRoot is the path in etcd for root coordinator registration
|
2021-06-16 18:35:59 +08:00
|
|
|
// etcdEndpoints are the address list for etcd end points
|
|
|
|
// timeout is default setting for each grpc call
|
2024-02-23 10:26:53 +08:00
|
|
|
func NewClient(ctx context.Context) (types.RootCoordClient, error) {
|
2023-10-27 07:36:12 +08:00
|
|
|
sess := sessionutil.NewSession(ctx)
|
2021-05-25 15:47:08 +08:00
|
|
|
if sess == nil {
|
2021-06-04 16:29:35 +08:00
|
|
|
err := fmt.Errorf("new session error, maybe can not connect to etcd")
|
2021-12-03 15:15:32 +08:00
|
|
|
log.Debug("QueryCoordClient NewClient failed", zap.Error(err))
|
2021-06-04 16:29:35 +08:00
|
|
|
return nil, err
|
2021-05-24 09:44:49 +08:00
|
|
|
}
|
2023-08-28 18:26:28 +08:00
|
|
|
config := &Params.RootCoordGrpcClientCfg
|
2021-12-03 15:15:32 +08:00
|
|
|
client := &Client{
|
2023-08-28 18:26:28 +08:00
|
|
|
grpcClient: grpcclient.NewClientBase[rootcoordpb.RootCoordClient](config, "milvus.proto.rootcoord.RootCoord"),
|
|
|
|
sess: sess,
|
2021-09-27 11:07:58 +08:00
|
|
|
}
|
2021-12-03 15:15:32 +08:00
|
|
|
client.grpcClient.SetRole(typeutil.RootCoordRole)
|
|
|
|
client.grpcClient.SetGetAddrFunc(client.getRootCoordAddr)
|
|
|
|
client.grpcClient.SetNewGrpcClientFunc(client.newGrpcClient)
|
2023-08-18 22:50:20 +08:00
|
|
|
client.grpcClient.SetSession(sess)
|
2021-09-27 11:07:58 +08:00
|
|
|
|
|
|
|
return client, nil
|
2021-01-19 14:44:03 +08:00
|
|
|
}
|
|
|
|
|
2021-09-23 11:41:53 +08:00
|
|
|
// Init initialize grpc parameters
|
2022-10-17 20:05:26 +08:00
|
|
|
func (c *Client) newGrpcClient(cc *grpc.ClientConn) rootcoordpb.RootCoordClient {
|
2021-12-03 15:15:32 +08:00
|
|
|
return rootcoordpb.NewRootCoordClient(cc)
|
2021-09-27 11:07:58 +08:00
|
|
|
}
|
|
|
|
|
2021-12-03 15:15:32 +08:00
|
|
|
func (c *Client) getRootCoordAddr() (string, error) {
|
|
|
|
key := c.grpcClient.GetRole()
|
|
|
|
msess, _, err := c.sess.GetSessions(key)
|
2021-09-17 19:45:42 +08:00
|
|
|
if err != nil {
|
2021-12-03 15:15:32 +08:00
|
|
|
log.Debug("RootCoordClient GetSessions failed", zap.Any("key", key))
|
|
|
|
return "", err
|
2021-09-17 19:45:42 +08:00
|
|
|
}
|
2021-12-03 15:15:32 +08:00
|
|
|
ms, ok := msess[key]
|
|
|
|
if !ok {
|
2022-02-10 13:51:47 +08:00
|
|
|
log.Warn("RootCoordClient mess key not exist", zap.Any("key", key))
|
2022-03-09 15:57:58 +08:00
|
|
|
return "", fmt.Errorf("find no available rootcoord, check rootcoord state")
|
2021-12-03 15:15:32 +08:00
|
|
|
}
|
2023-03-22 10:07:57 +08:00
|
|
|
log.Debug("RootCoordClient GetSessions success",
|
|
|
|
zap.String("address", ms.Address),
|
|
|
|
zap.Int64("serverID", ms.ServerID),
|
|
|
|
)
|
|
|
|
c.grpcClient.SetNodeID(ms.ServerID)
|
2021-12-03 15:15:32 +08:00
|
|
|
return ms.Address, nil
|
2021-09-16 18:15:49 +08:00
|
|
|
}
|
|
|
|
|
2023-09-26 09:57:25 +08:00
|
|
|
// Close terminate grpc connection
|
|
|
|
func (c *Client) Close() error {
|
2021-12-03 15:15:32 +08:00
|
|
|
return c.grpcClient.Close()
|
2021-01-19 14:44:03 +08:00
|
|
|
}
|
|
|
|
|
2023-05-24 19:25:26 +08:00
|
|
|
func wrapGrpcCall[T any](ctx context.Context, c *Client, call func(grpcClient rootcoordpb.RootCoordClient) (*T, error)) (*T, error) {
|
2022-10-17 20:05:26 +08:00
|
|
|
ret, err := c.grpcClient.ReCall(ctx, func(client rootcoordpb.RootCoordClient) (any, error) {
|
2021-11-18 11:17:12 +08:00
|
|
|
if !funcutil.CheckCtxValid(ctx) {
|
|
|
|
return nil, ctx.Err()
|
|
|
|
}
|
2023-05-24 19:25:26 +08:00
|
|
|
return call(client)
|
2021-05-24 09:44:49 +08:00
|
|
|
})
|
2021-09-17 19:45:42 +08:00
|
|
|
if err != nil || ret == nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-05-24 19:25:26 +08:00
|
|
|
return ret.(*T), err
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetComponentStates TODO: timeout need to be propagated through ctx
|
2023-09-26 09:57:25 +08:00
|
|
|
func (c *Client) GetComponentStates(ctx context.Context, req *milvuspb.GetComponentStatesRequest, opts ...grpc.CallOption) (*milvuspb.ComponentStates, error) {
|
2023-05-24 19:25:26 +08:00
|
|
|
return wrapGrpcCall(ctx, c, func(client rootcoordpb.RootCoordClient) (*milvuspb.ComponentStates, error) {
|
|
|
|
return client.GetComponentStates(ctx, &milvuspb.GetComponentStatesRequest{})
|
|
|
|
})
|
2021-03-12 14:22:09 +08:00
|
|
|
}
|
2021-09-23 11:41:53 +08:00
|
|
|
|
|
|
|
// GetTimeTickChannel get timetick channel name
|
2023-09-26 09:57:25 +08:00
|
|
|
func (c *Client) GetTimeTickChannel(ctx context.Context, req *internalpb.GetTimeTickChannelRequest, opts ...grpc.CallOption) (*milvuspb.StringResponse, error) {
|
2023-05-24 19:25:26 +08:00
|
|
|
return wrapGrpcCall(ctx, c, func(client rootcoordpb.RootCoordClient) (*milvuspb.StringResponse, error) {
|
2022-10-17 20:05:26 +08:00
|
|
|
return client.GetTimeTickChannel(ctx, &internalpb.GetTimeTickChannelRequest{})
|
2021-05-24 09:44:49 +08:00
|
|
|
})
|
2021-03-12 14:22:09 +08:00
|
|
|
}
|
|
|
|
|
2021-06-04 16:29:35 +08:00
|
|
|
// GetStatisticsChannel just define a channel, not used currently
|
2023-09-26 09:57:25 +08:00
|
|
|
func (c *Client) GetStatisticsChannel(ctx context.Context, req *internalpb.GetStatisticsChannelRequest, opts ...grpc.CallOption) (*milvuspb.StringResponse, error) {
|
2023-05-24 19:25:26 +08:00
|
|
|
return wrapGrpcCall(ctx, c, func(client rootcoordpb.RootCoordClient) (*milvuspb.StringResponse, error) {
|
2022-10-17 20:05:26 +08:00
|
|
|
return client.GetStatisticsChannel(ctx, &internalpb.GetStatisticsChannelRequest{})
|
2021-05-24 09:44:49 +08:00
|
|
|
})
|
2021-03-12 14:22:09 +08:00
|
|
|
}
|
|
|
|
|
2021-09-23 11:41:53 +08:00
|
|
|
// CreateCollection create collection
|
2023-09-26 09:57:25 +08:00
|
|
|
func (c *Client) CreateCollection(ctx context.Context, in *milvuspb.CreateCollectionRequest, opts ...grpc.CallOption) (*commonpb.Status, error) {
|
2022-10-19 10:01:26 +08:00
|
|
|
in = typeutil.Clone(in)
|
2022-10-24 23:43:30 +08:00
|
|
|
commonpbutil.UpdateMsgBase(
|
|
|
|
in.GetBase(),
|
2023-03-22 10:07:57 +08:00
|
|
|
commonpbutil.FillMsgBaseFromClient(paramtable.GetNodeID(), commonpbutil.WithTargetID(c.grpcClient.GetNodeID())),
|
2022-10-24 23:43:30 +08:00
|
|
|
)
|
2023-05-24 19:25:26 +08:00
|
|
|
return wrapGrpcCall(ctx, c, func(client rootcoordpb.RootCoordClient) (*commonpb.Status, error) {
|
2022-10-17 20:05:26 +08:00
|
|
|
return client.CreateCollection(ctx, in)
|
2021-05-24 09:44:49 +08:00
|
|
|
})
|
2021-01-19 14:44:03 +08:00
|
|
|
}
|
|
|
|
|
2021-09-23 11:41:53 +08:00
|
|
|
// DropCollection drop collection
|
2023-09-26 09:57:25 +08:00
|
|
|
func (c *Client) DropCollection(ctx context.Context, in *milvuspb.DropCollectionRequest, opts ...grpc.CallOption) (*commonpb.Status, error) {
|
2022-10-19 10:01:26 +08:00
|
|
|
in = typeutil.Clone(in)
|
2022-10-24 23:43:30 +08:00
|
|
|
commonpbutil.UpdateMsgBase(
|
|
|
|
in.GetBase(),
|
2023-03-22 10:07:57 +08:00
|
|
|
commonpbutil.FillMsgBaseFromClient(paramtable.GetNodeID(), commonpbutil.WithTargetID(c.grpcClient.GetNodeID())),
|
2022-10-24 23:43:30 +08:00
|
|
|
)
|
2023-05-24 19:25:26 +08:00
|
|
|
return wrapGrpcCall(ctx, c, func(client rootcoordpb.RootCoordClient) (*commonpb.Status, error) {
|
2022-10-17 20:05:26 +08:00
|
|
|
return client.DropCollection(ctx, in)
|
2021-05-24 09:44:49 +08:00
|
|
|
})
|
2021-01-19 14:44:03 +08:00
|
|
|
}
|
2021-05-24 09:44:49 +08:00
|
|
|
|
2021-09-23 11:41:53 +08:00
|
|
|
// HasCollection check collection existence
|
2023-09-26 09:57:25 +08:00
|
|
|
func (c *Client) HasCollection(ctx context.Context, in *milvuspb.HasCollectionRequest, opts ...grpc.CallOption) (*milvuspb.BoolResponse, error) {
|
2022-10-19 10:01:26 +08:00
|
|
|
in = typeutil.Clone(in)
|
2022-10-24 23:43:30 +08:00
|
|
|
commonpbutil.UpdateMsgBase(
|
|
|
|
in.GetBase(),
|
2023-03-22 10:07:57 +08:00
|
|
|
commonpbutil.FillMsgBaseFromClient(paramtable.GetNodeID(), commonpbutil.WithTargetID(c.grpcClient.GetNodeID())),
|
2022-10-24 23:43:30 +08:00
|
|
|
)
|
2023-05-24 19:25:26 +08:00
|
|
|
return wrapGrpcCall(ctx, c, func(client rootcoordpb.RootCoordClient) (*milvuspb.BoolResponse, error) {
|
2022-10-17 20:05:26 +08:00
|
|
|
return client.HasCollection(ctx, in)
|
2021-05-24 09:44:49 +08:00
|
|
|
})
|
2021-01-19 14:44:03 +08:00
|
|
|
}
|
2021-09-23 11:41:53 +08:00
|
|
|
|
|
|
|
// DescribeCollection return collection info
|
2023-09-26 09:57:25 +08:00
|
|
|
func (c *Client) DescribeCollection(ctx context.Context, in *milvuspb.DescribeCollectionRequest, opts ...grpc.CallOption) (*milvuspb.DescribeCollectionResponse, error) {
|
2022-10-19 10:01:26 +08:00
|
|
|
in = typeutil.Clone(in)
|
2022-10-24 23:43:30 +08:00
|
|
|
commonpbutil.UpdateMsgBase(
|
|
|
|
in.GetBase(),
|
2023-03-22 10:07:57 +08:00
|
|
|
commonpbutil.FillMsgBaseFromClient(paramtable.GetNodeID(), commonpbutil.WithTargetID(c.grpcClient.GetNodeID())),
|
2022-10-24 23:43:30 +08:00
|
|
|
)
|
2023-05-24 19:25:26 +08:00
|
|
|
return wrapGrpcCall(ctx, c, func(client rootcoordpb.RootCoordClient) (*milvuspb.DescribeCollectionResponse, error) {
|
2022-10-17 20:05:26 +08:00
|
|
|
return client.DescribeCollection(ctx, in)
|
2021-05-24 09:44:49 +08:00
|
|
|
})
|
2021-01-19 14:44:03 +08:00
|
|
|
}
|
2021-01-20 09:36:50 +08:00
|
|
|
|
2023-01-12 10:09:39 +08:00
|
|
|
// describeCollectionInternal return collection info
|
2023-09-26 09:57:25 +08:00
|
|
|
func (c *Client) describeCollectionInternal(ctx context.Context, in *milvuspb.DescribeCollectionRequest, opts ...grpc.CallOption) (*milvuspb.DescribeCollectionResponse, error) {
|
2023-01-04 16:37:35 +08:00
|
|
|
in = typeutil.Clone(in)
|
|
|
|
commonpbutil.UpdateMsgBase(
|
|
|
|
in.GetBase(),
|
2023-03-22 10:07:57 +08:00
|
|
|
commonpbutil.FillMsgBaseFromClient(paramtable.GetNodeID(), commonpbutil.WithTargetID(c.grpcClient.GetNodeID())),
|
2023-01-04 16:37:35 +08:00
|
|
|
)
|
2023-05-24 19:25:26 +08:00
|
|
|
return wrapGrpcCall(ctx, c, func(client rootcoordpb.RootCoordClient) (*milvuspb.DescribeCollectionResponse, error) {
|
2023-01-04 16:37:35 +08:00
|
|
|
return client.DescribeCollectionInternal(ctx, in)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2023-09-26 09:57:25 +08:00
|
|
|
func (c *Client) DescribeCollectionInternal(ctx context.Context, in *milvuspb.DescribeCollectionRequest, opts ...grpc.CallOption) (*milvuspb.DescribeCollectionResponse, error) {
|
2023-01-12 10:09:39 +08:00
|
|
|
resp, err := c.describeCollectionInternal(ctx, in)
|
|
|
|
status, ok := grpcStatus.FromError(err)
|
|
|
|
if ok && status.Code() == grpcCodes.Unimplemented {
|
|
|
|
return c.DescribeCollection(ctx, in)
|
|
|
|
}
|
|
|
|
return resp, err
|
|
|
|
}
|
|
|
|
|
2021-09-23 11:41:53 +08:00
|
|
|
// ShowCollections list all collection names
|
2023-09-26 09:57:25 +08:00
|
|
|
func (c *Client) ShowCollections(ctx context.Context, in *milvuspb.ShowCollectionsRequest, opts ...grpc.CallOption) (*milvuspb.ShowCollectionsResponse, error) {
|
2022-10-19 10:01:26 +08:00
|
|
|
in = typeutil.Clone(in)
|
2022-10-24 23:43:30 +08:00
|
|
|
commonpbutil.UpdateMsgBase(
|
|
|
|
in.GetBase(),
|
2023-03-22 10:07:57 +08:00
|
|
|
commonpbutil.FillMsgBaseFromClient(paramtable.GetNodeID(), commonpbutil.WithTargetID(c.grpcClient.GetNodeID())),
|
2022-10-24 23:43:30 +08:00
|
|
|
)
|
2023-05-24 19:25:26 +08:00
|
|
|
return wrapGrpcCall(ctx, c, func(client rootcoordpb.RootCoordClient) (*milvuspb.ShowCollectionsResponse, error) {
|
2022-10-17 20:05:26 +08:00
|
|
|
return client.ShowCollections(ctx, in)
|
2021-05-24 09:44:49 +08:00
|
|
|
})
|
2021-01-19 14:44:03 +08:00
|
|
|
}
|
2021-09-23 11:41:53 +08:00
|
|
|
|
2023-09-26 09:57:25 +08:00
|
|
|
func (c *Client) AlterCollection(ctx context.Context, request *milvuspb.AlterCollectionRequest, opts ...grpc.CallOption) (*commonpb.Status, error) {
|
2022-10-19 10:01:26 +08:00
|
|
|
request = typeutil.Clone(request)
|
2022-10-24 23:43:30 +08:00
|
|
|
commonpbutil.UpdateMsgBase(
|
|
|
|
request.GetBase(),
|
2023-03-22 10:07:57 +08:00
|
|
|
commonpbutil.FillMsgBaseFromClient(paramtable.GetNodeID(), commonpbutil.WithTargetID(c.grpcClient.GetNodeID())),
|
2022-10-24 23:43:30 +08:00
|
|
|
)
|
2023-05-24 19:25:26 +08:00
|
|
|
return wrapGrpcCall(ctx, c, func(client rootcoordpb.RootCoordClient) (*commonpb.Status, error) {
|
2022-10-17 20:05:26 +08:00
|
|
|
return client.AlterCollection(ctx, request)
|
2022-10-10 20:31:22 +08:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2021-09-23 11:41:53 +08:00
|
|
|
// CreatePartition create partition
|
2023-09-26 09:57:25 +08:00
|
|
|
func (c *Client) CreatePartition(ctx context.Context, in *milvuspb.CreatePartitionRequest, opts ...grpc.CallOption) (*commonpb.Status, error) {
|
2022-10-19 10:01:26 +08:00
|
|
|
in = typeutil.Clone(in)
|
2022-10-24 23:43:30 +08:00
|
|
|
commonpbutil.UpdateMsgBase(
|
|
|
|
in.GetBase(),
|
2023-03-22 10:07:57 +08:00
|
|
|
commonpbutil.FillMsgBaseFromClient(paramtable.GetNodeID(), commonpbutil.WithTargetID(c.grpcClient.GetNodeID())),
|
2022-10-24 23:43:30 +08:00
|
|
|
)
|
2023-05-24 19:25:26 +08:00
|
|
|
return wrapGrpcCall(ctx, c, func(client rootcoordpb.RootCoordClient) (*commonpb.Status, error) {
|
2022-10-17 20:05:26 +08:00
|
|
|
return client.CreatePartition(ctx, in)
|
2021-05-24 09:44:49 +08:00
|
|
|
})
|
2021-01-19 14:44:03 +08:00
|
|
|
}
|
2021-01-20 09:36:50 +08:00
|
|
|
|
2021-09-23 11:41:53 +08:00
|
|
|
// DropPartition drop partition
|
2023-09-26 09:57:25 +08:00
|
|
|
func (c *Client) DropPartition(ctx context.Context, in *milvuspb.DropPartitionRequest, opts ...grpc.CallOption) (*commonpb.Status, error) {
|
2022-10-19 10:01:26 +08:00
|
|
|
in = typeutil.Clone(in)
|
2022-10-24 23:43:30 +08:00
|
|
|
commonpbutil.UpdateMsgBase(
|
|
|
|
in.GetBase(),
|
2023-03-22 10:07:57 +08:00
|
|
|
commonpbutil.FillMsgBaseFromClient(paramtable.GetNodeID(), commonpbutil.WithTargetID(c.grpcClient.GetNodeID())),
|
2022-10-24 23:43:30 +08:00
|
|
|
)
|
2023-05-24 19:25:26 +08:00
|
|
|
return wrapGrpcCall(ctx, c, func(client rootcoordpb.RootCoordClient) (*commonpb.Status, error) {
|
2022-10-17 20:05:26 +08:00
|
|
|
return client.DropPartition(ctx, in)
|
2021-05-24 09:44:49 +08:00
|
|
|
})
|
2021-01-19 14:44:03 +08:00
|
|
|
}
|
2021-01-20 09:36:50 +08:00
|
|
|
|
2021-09-23 11:41:53 +08:00
|
|
|
// HasPartition check partition existence
|
2023-09-26 09:57:25 +08:00
|
|
|
func (c *Client) HasPartition(ctx context.Context, in *milvuspb.HasPartitionRequest, opts ...grpc.CallOption) (*milvuspb.BoolResponse, error) {
|
2022-10-19 10:01:26 +08:00
|
|
|
in = typeutil.Clone(in)
|
2022-10-24 23:43:30 +08:00
|
|
|
commonpbutil.UpdateMsgBase(
|
|
|
|
in.GetBase(),
|
2023-03-22 10:07:57 +08:00
|
|
|
commonpbutil.FillMsgBaseFromClient(paramtable.GetNodeID(), commonpbutil.WithTargetID(c.grpcClient.GetNodeID())),
|
2022-10-24 23:43:30 +08:00
|
|
|
)
|
2023-05-24 19:25:26 +08:00
|
|
|
return wrapGrpcCall(ctx, c, func(client rootcoordpb.RootCoordClient) (*milvuspb.BoolResponse, error) {
|
2022-10-17 20:05:26 +08:00
|
|
|
return client.HasPartition(ctx, in)
|
2021-05-24 09:44:49 +08:00
|
|
|
})
|
2021-01-19 14:44:03 +08:00
|
|
|
}
|
2021-01-20 09:36:50 +08:00
|
|
|
|
2021-09-23 11:41:53 +08:00
|
|
|
// ShowPartitions list all partitions in collection
|
2023-09-26 09:57:25 +08:00
|
|
|
func (c *Client) ShowPartitions(ctx context.Context, in *milvuspb.ShowPartitionsRequest, opts ...grpc.CallOption) (*milvuspb.ShowPartitionsResponse, error) {
|
2022-10-19 10:01:26 +08:00
|
|
|
in = typeutil.Clone(in)
|
2022-10-24 23:43:30 +08:00
|
|
|
commonpbutil.UpdateMsgBase(
|
|
|
|
in.GetBase(),
|
2023-03-22 10:07:57 +08:00
|
|
|
commonpbutil.FillMsgBaseFromClient(paramtable.GetNodeID(), commonpbutil.WithTargetID(c.grpcClient.GetNodeID())),
|
2022-10-24 23:43:30 +08:00
|
|
|
)
|
2023-05-24 19:25:26 +08:00
|
|
|
return wrapGrpcCall(ctx, c, func(client rootcoordpb.RootCoordClient) (*milvuspb.ShowPartitionsResponse, error) {
|
2022-10-17 20:05:26 +08:00
|
|
|
return client.ShowPartitions(ctx, in)
|
2021-05-24 09:44:49 +08:00
|
|
|
})
|
2021-01-19 14:44:03 +08:00
|
|
|
}
|
|
|
|
|
2023-01-12 10:09:39 +08:00
|
|
|
// showPartitionsInternal list all partitions in collection
|
2023-09-26 09:57:25 +08:00
|
|
|
func (c *Client) showPartitionsInternal(ctx context.Context, in *milvuspb.ShowPartitionsRequest, opts ...grpc.CallOption) (*milvuspb.ShowPartitionsResponse, error) {
|
2023-01-04 16:37:35 +08:00
|
|
|
in = typeutil.Clone(in)
|
|
|
|
commonpbutil.UpdateMsgBase(
|
|
|
|
in.GetBase(),
|
2023-03-22 10:07:57 +08:00
|
|
|
commonpbutil.FillMsgBaseFromClient(paramtable.GetNodeID(), commonpbutil.WithTargetID(c.grpcClient.GetNodeID())),
|
2023-01-04 16:37:35 +08:00
|
|
|
)
|
2023-05-24 19:25:26 +08:00
|
|
|
return wrapGrpcCall(ctx, c, func(client rootcoordpb.RootCoordClient) (*milvuspb.ShowPartitionsResponse, error) {
|
2023-01-04 16:37:35 +08:00
|
|
|
return client.ShowPartitionsInternal(ctx, in)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2023-09-26 09:57:25 +08:00
|
|
|
func (c *Client) ShowPartitionsInternal(ctx context.Context, in *milvuspb.ShowPartitionsRequest, opts ...grpc.CallOption) (*milvuspb.ShowPartitionsResponse, error) {
|
2023-01-12 10:09:39 +08:00
|
|
|
resp, err := c.showPartitionsInternal(ctx, in)
|
|
|
|
status, ok := grpcStatus.FromError(err)
|
|
|
|
if ok && status.Code() == grpcCodes.Unimplemented {
|
|
|
|
return c.ShowPartitions(ctx, in)
|
|
|
|
}
|
|
|
|
return resp, err
|
|
|
|
}
|
|
|
|
|
2021-06-04 16:29:35 +08:00
|
|
|
// AllocTimestamp global timestamp allocator
|
2023-09-26 09:57:25 +08:00
|
|
|
func (c *Client) AllocTimestamp(ctx context.Context, in *rootcoordpb.AllocTimestampRequest, opts ...grpc.CallOption) (*rootcoordpb.AllocTimestampResponse, error) {
|
2022-10-19 10:01:26 +08:00
|
|
|
in = typeutil.Clone(in)
|
2022-10-24 23:43:30 +08:00
|
|
|
commonpbutil.UpdateMsgBase(
|
|
|
|
in.GetBase(),
|
2023-03-22 10:07:57 +08:00
|
|
|
commonpbutil.FillMsgBaseFromClient(paramtable.GetNodeID(), commonpbutil.WithTargetID(c.grpcClient.GetNodeID())),
|
2022-10-24 23:43:30 +08:00
|
|
|
)
|
2023-05-24 19:25:26 +08:00
|
|
|
return wrapGrpcCall(ctx, c, func(client rootcoordpb.RootCoordClient) (*rootcoordpb.AllocTimestampResponse, error) {
|
2022-10-17 20:05:26 +08:00
|
|
|
return client.AllocTimestamp(ctx, in)
|
2021-05-24 09:44:49 +08:00
|
|
|
})
|
2021-01-19 14:44:03 +08:00
|
|
|
}
|
2021-05-21 16:08:12 +08:00
|
|
|
|
2021-09-23 11:41:53 +08:00
|
|
|
// AllocID global ID allocator
|
2023-09-26 09:57:25 +08:00
|
|
|
func (c *Client) AllocID(ctx context.Context, in *rootcoordpb.AllocIDRequest, opts ...grpc.CallOption) (*rootcoordpb.AllocIDResponse, error) {
|
2022-10-19 10:01:26 +08:00
|
|
|
in = typeutil.Clone(in)
|
2022-10-24 23:43:30 +08:00
|
|
|
commonpbutil.UpdateMsgBase(
|
|
|
|
in.GetBase(),
|
2023-03-22 10:07:57 +08:00
|
|
|
commonpbutil.FillMsgBaseFromClient(paramtable.GetNodeID(), commonpbutil.WithTargetID(c.grpcClient.GetNodeID())),
|
2022-10-24 23:43:30 +08:00
|
|
|
)
|
2023-05-24 19:25:26 +08:00
|
|
|
return wrapGrpcCall(ctx, c, func(client rootcoordpb.RootCoordClient) (*rootcoordpb.AllocIDResponse, error) {
|
2022-10-17 20:05:26 +08:00
|
|
|
return client.AllocID(ctx, in)
|
2021-05-24 09:44:49 +08:00
|
|
|
})
|
2021-01-19 14:44:03 +08:00
|
|
|
}
|
|
|
|
|
2021-05-21 16:08:12 +08:00
|
|
|
// UpdateChannelTimeTick used to handle ChannelTimeTickMsg
|
2023-09-26 09:57:25 +08:00
|
|
|
func (c *Client) UpdateChannelTimeTick(ctx context.Context, in *internalpb.ChannelTimeTickMsg, opts ...grpc.CallOption) (*commonpb.Status, error) {
|
2022-10-19 10:01:26 +08:00
|
|
|
in = typeutil.Clone(in)
|
2022-10-24 23:43:30 +08:00
|
|
|
commonpbutil.UpdateMsgBase(
|
|
|
|
in.GetBase(),
|
2023-03-22 10:07:57 +08:00
|
|
|
commonpbutil.FillMsgBaseFromClient(paramtable.GetNodeID(), commonpbutil.WithTargetID(c.grpcClient.GetNodeID())),
|
2022-10-24 23:43:30 +08:00
|
|
|
)
|
2023-05-24 19:25:26 +08:00
|
|
|
return wrapGrpcCall(ctx, c, func(client rootcoordpb.RootCoordClient) (*commonpb.Status, error) {
|
2022-10-17 20:05:26 +08:00
|
|
|
return client.UpdateChannelTimeTick(ctx, in)
|
2021-05-24 09:44:49 +08:00
|
|
|
})
|
2021-05-21 16:08:12 +08:00
|
|
|
}
|
|
|
|
|
2021-09-23 11:41:53 +08:00
|
|
|
// ShowSegments list all segments
|
2023-09-26 09:57:25 +08:00
|
|
|
func (c *Client) ShowSegments(ctx context.Context, in *milvuspb.ShowSegmentsRequest, opts ...grpc.CallOption) (*milvuspb.ShowSegmentsResponse, error) {
|
2022-10-19 10:01:26 +08:00
|
|
|
in = typeutil.Clone(in)
|
2022-10-24 23:43:30 +08:00
|
|
|
commonpbutil.UpdateMsgBase(
|
|
|
|
in.GetBase(),
|
2023-03-22 10:07:57 +08:00
|
|
|
commonpbutil.FillMsgBaseFromClient(paramtable.GetNodeID(), commonpbutil.WithTargetID(c.grpcClient.GetNodeID())),
|
2022-10-24 23:43:30 +08:00
|
|
|
)
|
2023-05-24 19:25:26 +08:00
|
|
|
return wrapGrpcCall(ctx, c, func(client rootcoordpb.RootCoordClient) (*milvuspb.ShowSegmentsResponse, error) {
|
2022-10-17 20:05:26 +08:00
|
|
|
return client.ShowSegments(ctx, in)
|
2021-05-24 09:44:49 +08:00
|
|
|
})
|
2021-01-19 14:44:03 +08:00
|
|
|
}
|
2021-09-23 11:41:53 +08:00
|
|
|
|
2022-05-19 10:13:56 +08:00
|
|
|
// InvalidateCollectionMetaCache notifies RootCoord to release the collection cache in Proxies.
|
2023-09-26 09:57:25 +08:00
|
|
|
func (c *Client) InvalidateCollectionMetaCache(ctx context.Context, in *proxypb.InvalidateCollMetaCacheRequest, opts ...grpc.CallOption) (*commonpb.Status, error) {
|
2022-10-19 10:01:26 +08:00
|
|
|
in = typeutil.Clone(in)
|
2022-10-24 23:43:30 +08:00
|
|
|
commonpbutil.UpdateMsgBase(
|
|
|
|
in.GetBase(),
|
2023-03-22 10:07:57 +08:00
|
|
|
commonpbutil.FillMsgBaseFromClient(paramtable.GetNodeID(), commonpbutil.WithTargetID(c.grpcClient.GetNodeID())),
|
2022-10-24 23:43:30 +08:00
|
|
|
)
|
2023-05-24 19:25:26 +08:00
|
|
|
return wrapGrpcCall(ctx, c, func(client rootcoordpb.RootCoordClient) (*commonpb.Status, error) {
|
2022-10-17 20:05:26 +08:00
|
|
|
return client.InvalidateCollectionMetaCache(ctx, in)
|
2022-05-19 10:13:56 +08:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2022-08-12 13:20:39 +08:00
|
|
|
// ShowConfigurations gets specified configurations para of RootCoord
|
2023-09-26 09:57:25 +08:00
|
|
|
func (c *Client) ShowConfigurations(ctx context.Context, req *internalpb.ShowConfigurationsRequest, opts ...grpc.CallOption) (*internalpb.ShowConfigurationsResponse, error) {
|
2022-10-19 10:01:26 +08:00
|
|
|
req = typeutil.Clone(req)
|
2022-10-24 23:43:30 +08:00
|
|
|
commonpbutil.UpdateMsgBase(
|
|
|
|
req.GetBase(),
|
2023-03-22 10:07:57 +08:00
|
|
|
commonpbutil.FillMsgBaseFromClient(paramtable.GetNodeID(), commonpbutil.WithTargetID(c.grpcClient.GetNodeID())),
|
2022-10-24 23:43:30 +08:00
|
|
|
)
|
2023-05-24 19:25:26 +08:00
|
|
|
return wrapGrpcCall(ctx, c, func(client rootcoordpb.RootCoordClient) (*internalpb.ShowConfigurationsResponse, error) {
|
2022-10-17 20:05:26 +08:00
|
|
|
return client.ShowConfigurations(ctx, req)
|
2022-08-12 13:20:39 +08:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2021-09-23 11:41:53 +08:00
|
|
|
// GetMetrics get metrics
|
2023-09-26 09:57:25 +08:00
|
|
|
func (c *Client) GetMetrics(ctx context.Context, in *milvuspb.GetMetricsRequest, opts ...grpc.CallOption) (*milvuspb.GetMetricsResponse, error) {
|
2022-10-19 10:01:26 +08:00
|
|
|
in = typeutil.Clone(in)
|
2022-10-24 23:43:30 +08:00
|
|
|
commonpbutil.UpdateMsgBase(
|
|
|
|
in.GetBase(),
|
2023-03-22 10:07:57 +08:00
|
|
|
commonpbutil.FillMsgBaseFromClient(paramtable.GetNodeID(), commonpbutil.WithTargetID(c.grpcClient.GetNodeID())),
|
2022-10-24 23:43:30 +08:00
|
|
|
)
|
2023-05-24 19:25:26 +08:00
|
|
|
return wrapGrpcCall(ctx, c, func(client rootcoordpb.RootCoordClient) (*milvuspb.GetMetricsResponse, error) {
|
2022-10-17 20:05:26 +08:00
|
|
|
return client.GetMetrics(ctx, in)
|
2021-08-31 11:45:59 +08:00
|
|
|
})
|
|
|
|
}
|
2021-09-18 11:13:51 +08:00
|
|
|
|
2021-09-23 11:41:53 +08:00
|
|
|
// CreateAlias create collection alias
|
2023-09-26 09:57:25 +08:00
|
|
|
func (c *Client) CreateAlias(ctx context.Context, req *milvuspb.CreateAliasRequest, opts ...grpc.CallOption) (*commonpb.Status, error) {
|
2022-10-19 10:01:26 +08:00
|
|
|
req = typeutil.Clone(req)
|
2022-10-24 23:43:30 +08:00
|
|
|
commonpbutil.UpdateMsgBase(
|
|
|
|
req.GetBase(),
|
2023-03-22 10:07:57 +08:00
|
|
|
commonpbutil.FillMsgBaseFromClient(paramtable.GetNodeID(), commonpbutil.WithTargetID(c.grpcClient.GetNodeID())),
|
2022-10-24 23:43:30 +08:00
|
|
|
)
|
2023-05-24 19:25:26 +08:00
|
|
|
return wrapGrpcCall(ctx, c, func(client rootcoordpb.RootCoordClient) (*commonpb.Status, error) {
|
2022-10-17 20:05:26 +08:00
|
|
|
return client.CreateAlias(ctx, req)
|
2021-09-18 11:13:51 +08:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2021-09-23 11:41:53 +08:00
|
|
|
// DropAlias drop collection alias
|
2023-09-26 09:57:25 +08:00
|
|
|
func (c *Client) DropAlias(ctx context.Context, req *milvuspb.DropAliasRequest, opts ...grpc.CallOption) (*commonpb.Status, error) {
|
2022-10-19 10:01:26 +08:00
|
|
|
req = typeutil.Clone(req)
|
2022-10-24 23:43:30 +08:00
|
|
|
commonpbutil.UpdateMsgBase(
|
|
|
|
req.GetBase(),
|
2023-03-22 10:07:57 +08:00
|
|
|
commonpbutil.FillMsgBaseFromClient(paramtable.GetNodeID(), commonpbutil.WithTargetID(c.grpcClient.GetNodeID())),
|
2022-10-24 23:43:30 +08:00
|
|
|
)
|
2023-05-24 19:25:26 +08:00
|
|
|
return wrapGrpcCall(ctx, c, func(client rootcoordpb.RootCoordClient) (*commonpb.Status, error) {
|
2022-10-17 20:05:26 +08:00
|
|
|
return client.DropAlias(ctx, req)
|
2021-09-18 11:13:51 +08:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2021-09-23 11:41:53 +08:00
|
|
|
// AlterAlias alter collection alias
|
2023-09-26 09:57:25 +08:00
|
|
|
func (c *Client) AlterAlias(ctx context.Context, req *milvuspb.AlterAliasRequest, opts ...grpc.CallOption) (*commonpb.Status, error) {
|
2022-10-19 10:01:26 +08:00
|
|
|
req = typeutil.Clone(req)
|
2022-10-24 23:43:30 +08:00
|
|
|
commonpbutil.UpdateMsgBase(
|
|
|
|
req.GetBase(),
|
2023-03-22 10:07:57 +08:00
|
|
|
commonpbutil.FillMsgBaseFromClient(paramtable.GetNodeID(), commonpbutil.WithTargetID(c.grpcClient.GetNodeID())),
|
2022-10-24 23:43:30 +08:00
|
|
|
)
|
2023-05-24 19:25:26 +08:00
|
|
|
return wrapGrpcCall(ctx, c, func(client rootcoordpb.RootCoordClient) (*commonpb.Status, error) {
|
2022-10-17 20:05:26 +08:00
|
|
|
return client.AlterAlias(ctx, req)
|
2021-09-18 11:13:51 +08:00
|
|
|
})
|
|
|
|
}
|
2022-03-11 17:13:59 +08:00
|
|
|
|
2024-01-11 19:12:51 +08:00
|
|
|
// DescribeAlias describe alias
|
|
|
|
func (c *Client) DescribeAlias(ctx context.Context, req *milvuspb.DescribeAliasRequest, opts ...grpc.CallOption) (*milvuspb.DescribeAliasResponse, error) {
|
|
|
|
req = typeutil.Clone(req)
|
|
|
|
commonpbutil.UpdateMsgBase(
|
|
|
|
req.GetBase(),
|
|
|
|
commonpbutil.FillMsgBaseFromClient(paramtable.GetNodeID(), commonpbutil.WithTargetID(c.grpcClient.GetNodeID())),
|
|
|
|
)
|
|
|
|
return wrapGrpcCall(ctx, c, func(client rootcoordpb.RootCoordClient) (*milvuspb.DescribeAliasResponse, error) {
|
|
|
|
return client.DescribeAlias(ctx, req)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
// ListAliases list all aliases of db or collection
|
|
|
|
func (c *Client) ListAliases(ctx context.Context, req *milvuspb.ListAliasesRequest, opts ...grpc.CallOption) (*milvuspb.ListAliasesResponse, error) {
|
|
|
|
req = typeutil.Clone(req)
|
|
|
|
commonpbutil.UpdateMsgBase(
|
|
|
|
req.GetBase(),
|
|
|
|
commonpbutil.FillMsgBaseFromClient(paramtable.GetNodeID(), commonpbutil.WithTargetID(c.grpcClient.GetNodeID())),
|
|
|
|
)
|
|
|
|
return wrapGrpcCall(ctx, c, func(client rootcoordpb.RootCoordClient) (*milvuspb.ListAliasesResponse, error) {
|
|
|
|
return client.ListAliases(ctx, req)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2023-09-26 09:57:25 +08:00
|
|
|
func (c *Client) CreateCredential(ctx context.Context, req *internalpb.CredentialInfo, opts ...grpc.CallOption) (*commonpb.Status, error) {
|
2023-05-24 19:25:26 +08:00
|
|
|
return wrapGrpcCall(ctx, c, func(client rootcoordpb.RootCoordClient) (*commonpb.Status, error) {
|
2022-10-17 20:05:26 +08:00
|
|
|
return client.CreateCredential(ctx, req)
|
2022-04-11 19:49:34 +08:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2023-09-26 09:57:25 +08:00
|
|
|
func (c *Client) GetCredential(ctx context.Context, req *rootcoordpb.GetCredentialRequest, opts ...grpc.CallOption) (*rootcoordpb.GetCredentialResponse, error) {
|
2022-10-19 10:01:26 +08:00
|
|
|
req = typeutil.Clone(req)
|
2022-10-24 23:43:30 +08:00
|
|
|
commonpbutil.UpdateMsgBase(
|
|
|
|
req.GetBase(),
|
2023-03-22 10:07:57 +08:00
|
|
|
commonpbutil.FillMsgBaseFromClient(paramtable.GetNodeID(), commonpbutil.WithTargetID(c.grpcClient.GetNodeID())),
|
2022-10-24 23:43:30 +08:00
|
|
|
)
|
2023-05-24 19:25:26 +08:00
|
|
|
return wrapGrpcCall(ctx, c, func(client rootcoordpb.RootCoordClient) (*rootcoordpb.GetCredentialResponse, error) {
|
2022-10-17 20:05:26 +08:00
|
|
|
return client.GetCredential(ctx, req)
|
2022-04-11 19:49:34 +08:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2023-09-26 09:57:25 +08:00
|
|
|
func (c *Client) UpdateCredential(ctx context.Context, req *internalpb.CredentialInfo, opts ...grpc.CallOption) (*commonpb.Status, error) {
|
2023-05-24 19:25:26 +08:00
|
|
|
return wrapGrpcCall(ctx, c, func(client rootcoordpb.RootCoordClient) (*commonpb.Status, error) {
|
2022-10-17 20:05:26 +08:00
|
|
|
return client.UpdateCredential(ctx, req)
|
2022-04-11 19:49:34 +08:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2023-09-26 09:57:25 +08:00
|
|
|
func (c *Client) DeleteCredential(ctx context.Context, req *milvuspb.DeleteCredentialRequest, opts ...grpc.CallOption) (*commonpb.Status, error) {
|
2022-10-19 10:01:26 +08:00
|
|
|
req = typeutil.Clone(req)
|
2022-10-24 23:43:30 +08:00
|
|
|
commonpbutil.UpdateMsgBase(
|
|
|
|
req.GetBase(),
|
2023-03-22 10:07:57 +08:00
|
|
|
commonpbutil.FillMsgBaseFromClient(paramtable.GetNodeID(), commonpbutil.WithTargetID(c.grpcClient.GetNodeID())),
|
2022-10-24 23:43:30 +08:00
|
|
|
)
|
2023-05-24 19:25:26 +08:00
|
|
|
return wrapGrpcCall(ctx, c, func(client rootcoordpb.RootCoordClient) (*commonpb.Status, error) {
|
2022-10-17 20:05:26 +08:00
|
|
|
return client.DeleteCredential(ctx, req)
|
2022-04-11 19:49:34 +08:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2023-09-26 09:57:25 +08:00
|
|
|
func (c *Client) ListCredUsers(ctx context.Context, req *milvuspb.ListCredUsersRequest, opts ...grpc.CallOption) (*milvuspb.ListCredUsersResponse, error) {
|
2022-10-19 10:01:26 +08:00
|
|
|
req = typeutil.Clone(req)
|
2022-10-24 23:43:30 +08:00
|
|
|
commonpbutil.UpdateMsgBase(
|
|
|
|
req.GetBase(),
|
2023-03-22 10:07:57 +08:00
|
|
|
commonpbutil.FillMsgBaseFromClient(paramtable.GetNodeID(), commonpbutil.WithTargetID(c.grpcClient.GetNodeID())),
|
2022-10-24 23:43:30 +08:00
|
|
|
)
|
2023-05-24 19:25:26 +08:00
|
|
|
return wrapGrpcCall(ctx, c, func(client rootcoordpb.RootCoordClient) (*milvuspb.ListCredUsersResponse, error) {
|
2022-10-17 20:05:26 +08:00
|
|
|
return client.ListCredUsers(ctx, req)
|
2022-04-11 19:49:34 +08:00
|
|
|
})
|
|
|
|
}
|
2022-05-28 00:04:01 +08:00
|
|
|
|
2023-09-26 09:57:25 +08:00
|
|
|
func (c *Client) CreateRole(ctx context.Context, req *milvuspb.CreateRoleRequest, opts ...grpc.CallOption) (*commonpb.Status, error) {
|
2022-10-19 10:01:26 +08:00
|
|
|
req = typeutil.Clone(req)
|
2022-10-24 23:43:30 +08:00
|
|
|
commonpbutil.UpdateMsgBase(
|
|
|
|
req.GetBase(),
|
2023-03-22 10:07:57 +08:00
|
|
|
commonpbutil.FillMsgBaseFromClient(paramtable.GetNodeID(), commonpbutil.WithTargetID(c.grpcClient.GetNodeID())),
|
2022-10-24 23:43:30 +08:00
|
|
|
)
|
2023-05-24 19:25:26 +08:00
|
|
|
return wrapGrpcCall(ctx, c, func(client rootcoordpb.RootCoordClient) (*commonpb.Status, error) {
|
2022-10-17 20:05:26 +08:00
|
|
|
return client.CreateRole(ctx, req)
|
2022-05-28 00:04:01 +08:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2023-09-26 09:57:25 +08:00
|
|
|
func (c *Client) DropRole(ctx context.Context, req *milvuspb.DropRoleRequest, opts ...grpc.CallOption) (*commonpb.Status, error) {
|
2022-10-19 10:01:26 +08:00
|
|
|
req = typeutil.Clone(req)
|
2022-10-24 23:43:30 +08:00
|
|
|
commonpbutil.UpdateMsgBase(
|
|
|
|
req.GetBase(),
|
2023-03-22 10:07:57 +08:00
|
|
|
commonpbutil.FillMsgBaseFromClient(paramtable.GetNodeID(), commonpbutil.WithTargetID(c.grpcClient.GetNodeID())),
|
2022-10-24 23:43:30 +08:00
|
|
|
)
|
2023-05-24 19:25:26 +08:00
|
|
|
return wrapGrpcCall(ctx, c, func(client rootcoordpb.RootCoordClient) (*commonpb.Status, error) {
|
2022-10-17 20:05:26 +08:00
|
|
|
return client.DropRole(ctx, req)
|
2022-05-28 00:04:01 +08:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2023-09-26 09:57:25 +08:00
|
|
|
func (c *Client) OperateUserRole(ctx context.Context, req *milvuspb.OperateUserRoleRequest, opts ...grpc.CallOption) (*commonpb.Status, error) {
|
2022-10-19 10:01:26 +08:00
|
|
|
req = typeutil.Clone(req)
|
2022-10-24 23:43:30 +08:00
|
|
|
commonpbutil.UpdateMsgBase(
|
|
|
|
req.GetBase(),
|
2023-03-22 10:07:57 +08:00
|
|
|
commonpbutil.FillMsgBaseFromClient(paramtable.GetNodeID(), commonpbutil.WithTargetID(c.grpcClient.GetNodeID())),
|
2022-10-24 23:43:30 +08:00
|
|
|
)
|
2023-05-24 19:25:26 +08:00
|
|
|
return wrapGrpcCall(ctx, c, func(client rootcoordpb.RootCoordClient) (*commonpb.Status, error) {
|
2022-10-17 20:05:26 +08:00
|
|
|
return client.OperateUserRole(ctx, req)
|
2022-05-28 00:04:01 +08:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2023-09-26 09:57:25 +08:00
|
|
|
func (c *Client) SelectRole(ctx context.Context, req *milvuspb.SelectRoleRequest, opts ...grpc.CallOption) (*milvuspb.SelectRoleResponse, error) {
|
2022-10-19 10:01:26 +08:00
|
|
|
req = typeutil.Clone(req)
|
2022-10-24 23:43:30 +08:00
|
|
|
commonpbutil.UpdateMsgBase(
|
|
|
|
req.GetBase(),
|
2023-03-22 10:07:57 +08:00
|
|
|
commonpbutil.FillMsgBaseFromClient(paramtable.GetNodeID(), commonpbutil.WithTargetID(c.grpcClient.GetNodeID())),
|
2022-10-24 23:43:30 +08:00
|
|
|
)
|
2023-05-24 19:25:26 +08:00
|
|
|
return wrapGrpcCall(ctx, c, func(client rootcoordpb.RootCoordClient) (*milvuspb.SelectRoleResponse, error) {
|
2022-10-17 20:05:26 +08:00
|
|
|
return client.SelectRole(ctx, req)
|
2022-05-28 00:04:01 +08:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2023-09-26 09:57:25 +08:00
|
|
|
func (c *Client) SelectUser(ctx context.Context, req *milvuspb.SelectUserRequest, opts ...grpc.CallOption) (*milvuspb.SelectUserResponse, error) {
|
2022-10-19 10:01:26 +08:00
|
|
|
req = typeutil.Clone(req)
|
2022-10-24 23:43:30 +08:00
|
|
|
commonpbutil.UpdateMsgBase(
|
|
|
|
req.GetBase(),
|
2023-03-22 10:07:57 +08:00
|
|
|
commonpbutil.FillMsgBaseFromClient(paramtable.GetNodeID(), commonpbutil.WithTargetID(c.grpcClient.GetNodeID())),
|
2022-10-24 23:43:30 +08:00
|
|
|
)
|
2023-05-24 19:25:26 +08:00
|
|
|
return wrapGrpcCall(ctx, c, func(client rootcoordpb.RootCoordClient) (*milvuspb.SelectUserResponse, error) {
|
2022-10-17 20:05:26 +08:00
|
|
|
return client.SelectUser(ctx, req)
|
2022-05-28 00:04:01 +08:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2023-09-26 09:57:25 +08:00
|
|
|
func (c *Client) OperatePrivilege(ctx context.Context, req *milvuspb.OperatePrivilegeRequest, opts ...grpc.CallOption) (*commonpb.Status, error) {
|
2022-10-19 10:01:26 +08:00
|
|
|
req = typeutil.Clone(req)
|
2022-10-24 23:43:30 +08:00
|
|
|
commonpbutil.UpdateMsgBase(
|
|
|
|
req.GetBase(),
|
2023-03-22 10:07:57 +08:00
|
|
|
commonpbutil.FillMsgBaseFromClient(paramtable.GetNodeID(), commonpbutil.WithTargetID(c.grpcClient.GetNodeID())),
|
2022-10-24 23:43:30 +08:00
|
|
|
)
|
2023-05-24 19:25:26 +08:00
|
|
|
return wrapGrpcCall(ctx, c, func(client rootcoordpb.RootCoordClient) (*commonpb.Status, error) {
|
2022-10-17 20:05:26 +08:00
|
|
|
return client.OperatePrivilege(ctx, req)
|
2022-05-28 00:04:01 +08:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2023-09-26 09:57:25 +08:00
|
|
|
func (c *Client) SelectGrant(ctx context.Context, req *milvuspb.SelectGrantRequest, opts ...grpc.CallOption) (*milvuspb.SelectGrantResponse, error) {
|
2022-10-19 10:01:26 +08:00
|
|
|
req = typeutil.Clone(req)
|
2022-10-24 23:43:30 +08:00
|
|
|
commonpbutil.UpdateMsgBase(
|
|
|
|
req.GetBase(),
|
2023-03-22 10:07:57 +08:00
|
|
|
commonpbutil.FillMsgBaseFromClient(paramtable.GetNodeID(), commonpbutil.WithTargetID(c.grpcClient.GetNodeID())),
|
2022-10-24 23:43:30 +08:00
|
|
|
)
|
2023-05-24 19:25:26 +08:00
|
|
|
return wrapGrpcCall(ctx, c, func(client rootcoordpb.RootCoordClient) (*milvuspb.SelectGrantResponse, error) {
|
2022-10-17 20:05:26 +08:00
|
|
|
return client.SelectGrant(ctx, req)
|
2022-05-28 00:04:01 +08:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2023-09-26 09:57:25 +08:00
|
|
|
func (c *Client) ListPolicy(ctx context.Context, req *internalpb.ListPolicyRequest, opts ...grpc.CallOption) (*internalpb.ListPolicyResponse, error) {
|
2022-10-19 10:01:26 +08:00
|
|
|
req = typeutil.Clone(req)
|
2022-10-24 23:43:30 +08:00
|
|
|
commonpbutil.UpdateMsgBase(
|
|
|
|
req.GetBase(),
|
2023-03-22 10:07:57 +08:00
|
|
|
commonpbutil.FillMsgBaseFromClient(paramtable.GetNodeID(), commonpbutil.WithTargetID(c.grpcClient.GetNodeID())),
|
2022-10-24 23:43:30 +08:00
|
|
|
)
|
2023-05-24 19:25:26 +08:00
|
|
|
return wrapGrpcCall(ctx, c, func(client rootcoordpb.RootCoordClient) (*internalpb.ListPolicyResponse, error) {
|
2022-10-17 20:05:26 +08:00
|
|
|
return client.ListPolicy(ctx, req)
|
2022-05-28 00:04:01 +08:00
|
|
|
})
|
|
|
|
}
|
2022-10-18 13:39:26 +08:00
|
|
|
|
2023-09-26 09:57:25 +08:00
|
|
|
func (c *Client) CheckHealth(ctx context.Context, req *milvuspb.CheckHealthRequest, opts ...grpc.CallOption) (*milvuspb.CheckHealthResponse, error) {
|
2023-05-24 19:25:26 +08:00
|
|
|
return wrapGrpcCall(ctx, c, func(client rootcoordpb.RootCoordClient) (*milvuspb.CheckHealthResponse, error) {
|
2022-10-18 13:39:26 +08:00
|
|
|
return client.CheckHealth(ctx, req)
|
|
|
|
})
|
|
|
|
}
|
2023-01-19 14:13:43 +08:00
|
|
|
|
2023-09-26 09:57:25 +08:00
|
|
|
func (c *Client) RenameCollection(ctx context.Context, req *milvuspb.RenameCollectionRequest, opts ...grpc.CallOption) (*commonpb.Status, error) {
|
2023-01-19 14:13:43 +08:00
|
|
|
req = typeutil.Clone(req)
|
|
|
|
commonpbutil.UpdateMsgBase(
|
|
|
|
req.GetBase(),
|
2023-03-22 10:07:57 +08:00
|
|
|
commonpbutil.FillMsgBaseFromClient(paramtable.GetNodeID(), commonpbutil.WithTargetID(c.grpcClient.GetNodeID())),
|
2023-01-19 14:13:43 +08:00
|
|
|
)
|
2023-05-24 19:25:26 +08:00
|
|
|
return wrapGrpcCall(ctx, c, func(client rootcoordpb.RootCoordClient) (*commonpb.Status, error) {
|
2023-01-19 14:13:43 +08:00
|
|
|
return client.RenameCollection(ctx, req)
|
|
|
|
})
|
|
|
|
}
|
2023-06-25 17:20:43 +08:00
|
|
|
|
2023-09-26 09:57:25 +08:00
|
|
|
func (c *Client) CreateDatabase(ctx context.Context, in *milvuspb.CreateDatabaseRequest, opts ...grpc.CallOption) (*commonpb.Status, error) {
|
2023-06-25 17:20:43 +08:00
|
|
|
in = typeutil.Clone(in)
|
|
|
|
commonpbutil.UpdateMsgBase(
|
|
|
|
in.GetBase(),
|
|
|
|
commonpbutil.FillMsgBaseFromClient(paramtable.GetNodeID(), commonpbutil.WithTargetID(c.sess.ServerID)),
|
|
|
|
)
|
|
|
|
ret, err := c.grpcClient.ReCall(ctx, func(client rootcoordpb.RootCoordClient) (any, error) {
|
|
|
|
if !funcutil.CheckCtxValid(ctx) {
|
|
|
|
return nil, ctx.Err()
|
|
|
|
}
|
|
|
|
return client.CreateDatabase(ctx, in)
|
|
|
|
})
|
|
|
|
|
|
|
|
if err != nil || ret == nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return ret.(*commonpb.Status), err
|
|
|
|
}
|
|
|
|
|
2023-09-26 09:57:25 +08:00
|
|
|
func (c *Client) DropDatabase(ctx context.Context, in *milvuspb.DropDatabaseRequest, opts ...grpc.CallOption) (*commonpb.Status, error) {
|
2023-06-25 17:20:43 +08:00
|
|
|
in = typeutil.Clone(in)
|
|
|
|
commonpbutil.UpdateMsgBase(
|
|
|
|
in.GetBase(),
|
|
|
|
commonpbutil.FillMsgBaseFromClient(paramtable.GetNodeID(), commonpbutil.WithTargetID(c.sess.ServerID)),
|
|
|
|
)
|
|
|
|
ret, err := c.grpcClient.ReCall(ctx, func(client rootcoordpb.RootCoordClient) (any, error) {
|
|
|
|
if !funcutil.CheckCtxValid(ctx) {
|
|
|
|
return nil, ctx.Err()
|
|
|
|
}
|
|
|
|
return client.DropDatabase(ctx, in)
|
|
|
|
})
|
|
|
|
|
|
|
|
if err != nil || ret == nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return ret.(*commonpb.Status), err
|
|
|
|
}
|
|
|
|
|
2023-09-26 09:57:25 +08:00
|
|
|
func (c *Client) ListDatabases(ctx context.Context, in *milvuspb.ListDatabasesRequest, opts ...grpc.CallOption) (*milvuspb.ListDatabasesResponse, error) {
|
2023-06-25 17:20:43 +08:00
|
|
|
in = typeutil.Clone(in)
|
|
|
|
commonpbutil.UpdateMsgBase(
|
|
|
|
in.GetBase(),
|
|
|
|
commonpbutil.FillMsgBaseFromClient(paramtable.GetNodeID(), commonpbutil.WithTargetID(c.sess.ServerID)),
|
|
|
|
)
|
|
|
|
ret, err := c.grpcClient.ReCall(ctx, func(client rootcoordpb.RootCoordClient) (any, error) {
|
|
|
|
if !funcutil.CheckCtxValid(ctx) {
|
|
|
|
return nil, ctx.Err()
|
|
|
|
}
|
|
|
|
return client.ListDatabases(ctx, in)
|
|
|
|
})
|
|
|
|
|
|
|
|
if err != nil || ret == nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return ret.(*milvuspb.ListDatabasesResponse), err
|
|
|
|
}
|
2024-04-12 16:01:19 +08:00
|
|
|
|
|
|
|
func (c *Client) DescribeDatabase(ctx context.Context, req *rootcoordpb.DescribeDatabaseRequest, opts ...grpc.CallOption) (*rootcoordpb.DescribeDatabaseResponse, error) {
|
|
|
|
req = typeutil.Clone(req)
|
|
|
|
commonpbutil.UpdateMsgBase(
|
|
|
|
req.GetBase(),
|
|
|
|
commonpbutil.FillMsgBaseFromClient(paramtable.GetNodeID(), commonpbutil.WithTargetID(c.grpcClient.GetNodeID())),
|
|
|
|
)
|
|
|
|
return wrapGrpcCall(ctx, c, func(client rootcoordpb.RootCoordClient) (*rootcoordpb.DescribeDatabaseResponse, error) {
|
|
|
|
return client.DescribeDatabase(ctx, req)
|
|
|
|
})
|
|
|
|
}
|