2021-11-10 23:43:27 +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-08-18 10:12:10 +08:00
|
|
|
// with the License. You may obtain a copy of the License at
|
|
|
|
//
|
2021-11-10 23:43:27 +08:00
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
2021-08-18 10:12:10 +08:00
|
|
|
//
|
2021-11-10 23:43:27 +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-08-18 10:12:10 +08:00
|
|
|
|
2021-07-13 16:33:55 +08:00
|
|
|
package proxy
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"fmt"
|
|
|
|
|
2022-06-22 21:56:13 +08:00
|
|
|
"google.golang.org/grpc/codes"
|
|
|
|
"google.golang.org/grpc/status"
|
|
|
|
|
2022-10-16 20:49:27 +08:00
|
|
|
"github.com/milvus-io/milvus-proto/go-api/schemapb"
|
2021-07-13 16:33:55 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
// TODO(dragondriver): add more common error type
|
|
|
|
|
|
|
|
func errInvalidNumRows(numRows uint32) error {
|
|
|
|
return fmt.Errorf("invalid num_rows: %d", numRows)
|
|
|
|
}
|
|
|
|
|
|
|
|
func errNumRowsLessThanOrEqualToZero(numRows uint32) error {
|
|
|
|
return fmt.Errorf("num_rows(%d) should be greater than 0", numRows)
|
|
|
|
}
|
|
|
|
|
|
|
|
func errNumRowsOfFieldDataMismatchPassed(idx int, fieldNumRows, passedNumRows uint32) error {
|
|
|
|
return fmt.Errorf("the num_rows(%d) of %dth field is not equal to passed NumRows(%d)", fieldNumRows, idx, passedNumRows)
|
|
|
|
}
|
|
|
|
|
|
|
|
var errEmptyFieldData = errors.New("empty field data")
|
|
|
|
|
|
|
|
func errFieldsLessThanNeeded(fieldsNum, needed int) error {
|
|
|
|
return fmt.Errorf("the length(%d) of passed fields is less than needed(%d)", fieldsNum, needed)
|
|
|
|
}
|
|
|
|
|
|
|
|
func errUnsupportedDataType(dType schemapb.DataType) error {
|
|
|
|
return fmt.Errorf("%v is not supported now", dType)
|
|
|
|
}
|
|
|
|
|
|
|
|
func errUnsupportedDType(dType string) error {
|
|
|
|
return fmt.Errorf("%s is not supported now", dType)
|
|
|
|
}
|
|
|
|
|
|
|
|
func errInvalidDim(dim int) error {
|
|
|
|
return fmt.Errorf("invalid dim: %d", dim)
|
|
|
|
}
|
|
|
|
|
|
|
|
func errDimLessThanOrEqualToZero(dim int) error {
|
|
|
|
return fmt.Errorf("dim(%d) should be greater than 0", dim)
|
|
|
|
}
|
|
|
|
|
|
|
|
func errDimShouldDivide8(dim int) error {
|
|
|
|
return fmt.Errorf("dim(%d) should divide 8", dim)
|
|
|
|
}
|
2021-08-18 10:12:10 +08:00
|
|
|
|
|
|
|
func msgProxyIsUnhealthy(id UniqueID) string {
|
|
|
|
return fmt.Sprintf("proxy %d is unhealthy", id)
|
|
|
|
}
|
|
|
|
|
2021-10-14 19:16:39 +08:00
|
|
|
// errProxyIsUnhealthy returns an error represent proxy is unhealthy
|
2021-08-18 10:12:10 +08:00
|
|
|
func errProxyIsUnhealthy(id UniqueID) error {
|
|
|
|
return errors.New(msgProxyIsUnhealthy(id))
|
|
|
|
}
|
2022-04-11 19:49:34 +08:00
|
|
|
|
|
|
|
func ErrMissingMetadata() error {
|
2022-10-28 19:25:34 +08:00
|
|
|
return fmt.Errorf("auth check failure, due to occurs inner error: missing metadata")
|
2022-04-11 19:49:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func ErrUnauthenticated() error {
|
2022-10-28 19:25:34 +08:00
|
|
|
return fmt.Errorf("auth check failure, please check username and password are correct")
|
2022-04-11 19:49:34 +08:00
|
|
|
}
|
2022-04-14 20:01:34 +08:00
|
|
|
|
2022-04-20 17:23:46 +08:00
|
|
|
func ErrProxyNotReady() error {
|
2022-06-22 21:56:13 +08:00
|
|
|
return status.Errorf(codes.Unavailable, "internal: Milvus Proxy is not ready yet. please wait")
|
2022-04-14 20:01:34 +08:00
|
|
|
}
|
2022-10-25 11:29:30 +08:00
|
|
|
|
|
|
|
func ErrPartitionNotExist(partitionName string) error {
|
2022-10-28 17:01:32 +08:00
|
|
|
return fmt.Errorf("partition is not exist: %s", partitionName)
|
2022-10-25 11:29:30 +08:00
|
|
|
}
|