Upgrade proto to add error code field of Status (#22656)

Signed-off-by: yah01 <yang.cen@zilliz.com>
This commit is contained in:
yah01 2023-03-09 18:49:51 +08:00 committed by GitHub
parent d9908ff231
commit e4120d1671
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 303 additions and 202 deletions

7
go.mod
View File

@ -22,12 +22,11 @@ require (
github.com/golang/protobuf v1.5.2
github.com/google/btree v1.0.1
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0
github.com/jarcoal/httpmock v1.0.8
github.com/jinzhu/now v1.1.5 // indirect
github.com/klauspost/compress v1.14.4
github.com/lingdor/stackerror v0.0.0-20191119040541-976d8885ed76
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d
github.com/milvus-io/milvus-proto/go-api v0.0.0-20230303054144-16f081962572
github.com/milvus-io/milvus-proto/go-api v0.0.0-20230309062747-133bf302bb11
github.com/minio/minio-go/v7 v7.0.17
github.com/panjf2000/ants/v2 v2.4.8
github.com/prometheus/client_golang v1.11.1
@ -172,7 +171,7 @@ require (
google.golang.org/genproto v0.0.0-20220503193339-ba3ae3f07e29 // indirect
gopkg.in/ini.v1 v1.62.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1
gopkg.in/yaml.v3 v3.0.1 // indirect
sigs.k8s.io/yaml v1.2.0 // indirect
)
@ -181,7 +180,6 @@ require github.com/ianlancetaylor/cgosymbolizer v0.0.0-20221217025313-27d3c9f66b
require (
github.com/aliyun/credentials-go v1.2.6
github.com/cockroachdb/errors v1.9.1
github.com/pkg/errors v0.9.1
github.com/uber/jaeger-client-go v2.30.0+incompatible
go.opentelemetry.io/otel/exporters/jaeger v1.11.2
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.11.2
@ -202,6 +200,7 @@ require (
github.com/kr/pretty v0.3.0 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/rogpeppe/go-internal v1.8.1 // indirect
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.11.2 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.11.2 // indirect

6
go.sum
View File

@ -452,8 +452,6 @@ github.com/iris-contrib/go.uuid v2.0.0+incompatible/go.mod h1:iz2lgM/1UnEf1kP0L/
github.com/iris-contrib/jade v1.1.3/go.mod h1:H/geBymxJhShH5kecoiOCSssPX7QWYH7UaeZTSWddIk=
github.com/iris-contrib/pongo2 v0.0.1/go.mod h1:Ssh+00+3GAZqSQb30AvBRNxBx7rf0GqwkjqxNd0u65g=
github.com/iris-contrib/schema v0.0.1/go.mod h1:urYA3uvUNG1TIIjOSCzHr9/LmbQo8LrOcOqfqxa4hXw=
github.com/jarcoal/httpmock v1.0.8 h1:8kI16SoO6LQKgPE7PvQuV+YuD/inwHd7fOOe2zMbo4k=
github.com/jarcoal/httpmock v1.0.8/go.mod h1:ATjnClrvW/3tijVmpL/va5Z3aAyGvqU3gCT8nX0Txik=
github.com/jawher/mow.cli v1.0.4/go.mod h1:5hQj2V8g+qYmLUVWqu4Wuja1pI57M83EChYLVZ0sMKk=
github.com/jawher/mow.cli v1.2.0/go.mod h1:y+pcA3jBAdo/GIZx/0rFjw/K2bVEODP9rfZOfaiq8Ko=
github.com/jhump/gopoet v0.0.0-20190322174617-17282ff210b3/go.mod h1:me9yfT6IJSlOL3FCfrg+L6yzUEZ+5jW6WHt4Sk+UPUI=
@ -569,8 +567,8 @@ github.com/microcosm-cc/bluemonday v1.0.2/go.mod h1:iVP4YcDBq+n/5fb23BhYFvIMq/le
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
github.com/milvus-io/gorocksdb v0.0.0-20220624081344-8c5f4212846b h1:TfeY0NxYxZzUfIfYe5qYDBzt4ZYRqzUjTR6CvUzjat8=
github.com/milvus-io/gorocksdb v0.0.0-20220624081344-8c5f4212846b/go.mod h1:iwW+9cWfIzzDseEBCCeDSN5SD16Tidvy8cwQ7ZY8Qj4=
github.com/milvus-io/milvus-proto/go-api v0.0.0-20230303054144-16f081962572 h1:QOimLfT1VwjH9jUkq2SN3uT/WGfgcD4pYBoFOGUMwjM=
github.com/milvus-io/milvus-proto/go-api v0.0.0-20230303054144-16f081962572/go.mod h1:148qnlmZ0Fdm1Fq+Mj/OW2uDoEP25g3mjh0vMGtkgmk=
github.com/milvus-io/milvus-proto/go-api v0.0.0-20230309062747-133bf302bb11 h1:ly7SWpwWH0ezos2xw3HPOQCqxTdTjlpUSvfpguPg91c=
github.com/milvus-io/milvus-proto/go-api v0.0.0-20230309062747-133bf302bb11/go.mod h1:148qnlmZ0Fdm1Fq+Mj/OW2uDoEP25g3mjh0vMGtkgmk=
github.com/milvus-io/pulsar-client-go v0.6.10 h1:eqpJjU+/QX0iIhEo3nhOqMNXL+TyInAs1IAHZCrCM/A=
github.com/milvus-io/pulsar-client-go v0.6.10/go.mod h1:lQqCkgwDF8YFYjKA+zOheTk1tev2B+bKj5j7+nm8M1w=
github.com/minio/asm2plan9s v0.0.0-20200509001527-cdd76441f9d8 h1:AMFGa4R4MiIpspGNG7Z948v4n35fFGB3RR3G/ry4FWs=

View File

@ -27,6 +27,7 @@ PROTOBUF_CONSTEXPR Status::Status(
::_pbi::ConstantInitialized): _impl_{
/*decltype(_impl_.reason_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
, /*decltype(_impl_.error_code_)*/0
, /*decltype(_impl_.code_)*/0
, /*decltype(_impl_._cached_size_)*/{}} {}
struct StatusDefaultTypeInternal {
PROTOBUF_CONSTEXPR StatusDefaultTypeInternal()
@ -210,6 +211,7 @@ const uint32_t TableStruct_common_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(p
~0u, // no _inlined_string_donated_
PROTOBUF_FIELD_OFFSET(::milvus::proto::common::Status, _impl_.error_code_),
PROTOBUF_FIELD_OFFSET(::milvus::proto::common::Status, _impl_.reason_),
PROTOBUF_FIELD_OFFSET(::milvus::proto::common::Status, _impl_.code_),
~0u, // no _has_bits_
PROTOBUF_FIELD_OFFSET(::milvus::proto::common::KeyValuePair, _internal_metadata_),
~0u, // no _extensions_
@ -304,17 +306,17 @@ const uint32_t TableStruct_common_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(p
};
static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
{ 0, -1, -1, sizeof(::milvus::proto::common::Status)},
{ 8, -1, -1, sizeof(::milvus::proto::common::KeyValuePair)},
{ 16, -1, -1, sizeof(::milvus::proto::common::KeyDataPair)},
{ 24, -1, -1, sizeof(::milvus::proto::common::Blob)},
{ 31, -1, -1, sizeof(::milvus::proto::common::PlaceholderValue)},
{ 40, -1, -1, sizeof(::milvus::proto::common::PlaceholderGroup)},
{ 47, -1, -1, sizeof(::milvus::proto::common::Address)},
{ 55, -1, -1, sizeof(::milvus::proto::common::MsgBase)},
{ 66, -1, -1, sizeof(::milvus::proto::common::MsgHeader)},
{ 73, -1, -1, sizeof(::milvus::proto::common::DMLMsgHeader)},
{ 81, -1, -1, sizeof(::milvus::proto::common::PrivilegeExt)},
{ 91, -1, -1, sizeof(::milvus::proto::common::SegmentStats)},
{ 9, -1, -1, sizeof(::milvus::proto::common::KeyValuePair)},
{ 17, -1, -1, sizeof(::milvus::proto::common::KeyDataPair)},
{ 25, -1, -1, sizeof(::milvus::proto::common::Blob)},
{ 32, -1, -1, sizeof(::milvus::proto::common::PlaceholderValue)},
{ 41, -1, -1, sizeof(::milvus::proto::common::PlaceholderGroup)},
{ 48, -1, -1, sizeof(::milvus::proto::common::Address)},
{ 56, -1, -1, sizeof(::milvus::proto::common::MsgBase)},
{ 67, -1, -1, sizeof(::milvus::proto::common::MsgHeader)},
{ 74, -1, -1, sizeof(::milvus::proto::common::DMLMsgHeader)},
{ 82, -1, -1, sizeof(::milvus::proto::common::PrivilegeExt)},
{ 92, -1, -1, sizeof(::milvus::proto::common::SegmentStats)},
};
static const ::_pb::Message* const file_default_instances[] = {
@ -334,168 +336,168 @@ static const ::_pb::Message* const file_default_instances[] = {
const char descriptor_table_protodef_common_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) =
"\n\014common.proto\022\023milvus.proto.common\032 goo"
"gle/protobuf/descriptor.proto\"L\n\006Status\022"
"gle/protobuf/descriptor.proto\"Z\n\006Status\022"
"2\n\nerror_code\030\001 \001(\0162\036.milvus.proto.commo"
"n.ErrorCode\022\016\n\006reason\030\002 \001(\t\"*\n\014KeyValueP"
"air\022\013\n\003key\030\001 \001(\t\022\r\n\005value\030\002 \001(\t\"(\n\013KeyDa"
"taPair\022\013\n\003key\030\001 \001(\t\022\014\n\004data\030\002 \001(\014\"\025\n\004Blo"
"b\022\r\n\005value\030\001 \001(\014\"c\n\020PlaceholderValue\022\013\n\003"
"tag\030\001 \001(\t\0222\n\004type\030\002 \001(\0162$.milvus.proto.c"
"ommon.PlaceholderType\022\016\n\006values\030\003 \003(\014\"O\n"
"\020PlaceholderGroup\022;\n\014placeholders\030\001 \003(\0132"
"%.milvus.proto.common.PlaceholderValue\"#"
"\n\007Address\022\n\n\002ip\030\001 \001(\t\022\014\n\004port\030\002 \001(\003\"\177\n\007M"
"sgBase\022.\n\010msg_type\030\001 \001(\0162\034.milvus.proto."
"common.MsgType\022\r\n\005msgID\030\002 \001(\003\022\021\n\ttimesta"
"mp\030\003 \001(\004\022\020\n\010sourceID\030\004 \001(\003\022\020\n\010targetID\030\005"
" \001(\003\"7\n\tMsgHeader\022*\n\004base\030\001 \001(\0132\034.milvus"
".proto.common.MsgBase\"M\n\014DMLMsgHeader\022*\n"
"\004base\030\001 \001(\0132\034.milvus.proto.common.MsgBas"
"e\022\021\n\tshardName\030\002 \001(\t\"\273\001\n\014PrivilegeExt\0224\n"
"\013object_type\030\001 \001(\0162\037.milvus.proto.common"
".ObjectType\022>\n\020object_privilege\030\002 \001(\0162$."
"milvus.proto.common.ObjectPrivilege\022\031\n\021o"
"bject_name_index\030\003 \001(\005\022\032\n\022object_name_in"
"dexs\030\004 \001(\005\"2\n\014SegmentStats\022\021\n\tSegmentID\030"
"\001 \001(\003\022\017\n\007NumRows\030\002 \001(\003*\303\n\n\tErrorCode\022\013\n\007"
"Success\020\000\022\023\n\017UnexpectedError\020\001\022\021\n\rConnec"
"tFailed\020\002\022\024\n\020PermissionDenied\020\003\022\027\n\023Colle"
"ctionNotExists\020\004\022\023\n\017IllegalArgument\020\005\022\024\n"
"\020IllegalDimension\020\007\022\024\n\020IllegalIndexType\020"
"\010\022\031\n\025IllegalCollectionName\020\t\022\017\n\013IllegalT"
"OPK\020\n\022\024\n\020IllegalRowRecord\020\013\022\023\n\017IllegalVe"
"ctorID\020\014\022\027\n\023IllegalSearchResult\020\r\022\020\n\014Fil"
"eNotFound\020\016\022\016\n\nMetaFailed\020\017\022\017\n\013CacheFail"
"ed\020\020\022\026\n\022CannotCreateFolder\020\021\022\024\n\020CannotCr"
"eateFile\020\022\022\026\n\022CannotDeleteFolder\020\023\022\024\n\020Ca"
"nnotDeleteFile\020\024\022\023\n\017BuildIndexError\020\025\022\020\n"
"\014IllegalNLIST\020\026\022\025\n\021IllegalMetricType\020\027\022\017"
"\n\013OutOfMemory\020\030\022\021\n\rIndexNotExist\020\031\022\023\n\017Em"
"ptyCollection\020\032\022\033\n\027UpdateImportTaskFailu"
"re\020\033\022\032\n\026CollectionNameNotFound\020\034\022\033\n\027Crea"
"teCredentialFailure\020\035\022\033\n\027UpdateCredentia"
"lFailure\020\036\022\033\n\027DeleteCredentialFailure\020\037\022"
"\030\n\024GetCredentialFailure\020 \022\030\n\024ListCredUse"
"rsFailure\020!\022\022\n\016GetUserFailure\020\"\022\025\n\021Creat"
"eRoleFailure\020#\022\023\n\017DropRoleFailure\020$\022\032\n\026O"
"perateUserRoleFailure\020%\022\025\n\021SelectRoleFai"
"lure\020&\022\025\n\021SelectUserFailure\020\'\022\031\n\025SelectR"
"esourceFailure\020(\022\033\n\027OperatePrivilegeFail"
"ure\020)\022\026\n\022SelectGrantFailure\020*\022!\n\035Refresh"
"PolicyInfoCacheFailure\020+\022\025\n\021ListPolicyFa"
"ilure\020,\022\022\n\016NotShardLeader\020-\022\026\n\022NoReplica"
"Available\020.\022\023\n\017SegmentNotFound\020/\022\r\n\tForc"
"eDeny\0200\022\r\n\tRateLimit\0201\022\022\n\016NodeIDNotMatch"
"\0202\022\024\n\020UpsertAutoIDTrue\0203\022\034\n\030Insufficient"
"MemoryToLoad\0204\022\030\n\024MemoryQuotaExhausted\0205"
"\022\026\n\022DiskQuotaExhausted\0206\022\025\n\021TimeTickLong"
"Delay\0207\022\021\n\rNotReadyServe\0208\022\033\n\027NotReadyCo"
"ordActivating\0209\022\017\n\013DataCoordNA\020d\022\022\n\rDDRe"
"questRace\020\350\007*c\n\nIndexState\022\022\n\016IndexState"
"None\020\000\022\014\n\010Unissued\020\001\022\016\n\nInProgress\020\002\022\014\n\010"
"Finished\020\003\022\n\n\006Failed\020\004\022\t\n\005Retry\020\005*\202\001\n\014Se"
"gmentState\022\024\n\020SegmentStateNone\020\000\022\014\n\010NotE"
"xist\020\001\022\013\n\007Growing\020\002\022\n\n\006Sealed\020\003\022\013\n\007Flush"
"ed\020\004\022\014\n\010Flushing\020\005\022\013\n\007Dropped\020\006\022\r\n\tImpor"
"ting\020\007*>\n\017PlaceholderType\022\010\n\004None\020\000\022\020\n\014B"
"inaryVector\020d\022\017\n\013FloatVector\020e*\300\016\n\007MsgTy"
"pe\022\r\n\tUndefined\020\000\022\024\n\020CreateCollection\020d\022"
"\022\n\016DropCollection\020e\022\021\n\rHasCollection\020f\022\026"
"\n\022DescribeCollection\020g\022\023\n\017ShowCollection"
"s\020h\022\024\n\020GetSystemConfigs\020i\022\022\n\016LoadCollect"
"ion\020j\022\025\n\021ReleaseCollection\020k\022\017\n\013CreateAl"
"ias\020l\022\r\n\tDropAlias\020m\022\016\n\nAlterAlias\020n\022\023\n\017"
"AlterCollection\020o\022\024\n\020RenameCollection\020p\022"
"\024\n\017CreatePartition\020\310\001\022\022\n\rDropPartition\020\311"
"\001\022\021\n\014HasPartition\020\312\001\022\026\n\021DescribePartitio"
"n\020\313\001\022\023\n\016ShowPartitions\020\314\001\022\023\n\016LoadPartiti"
"ons\020\315\001\022\026\n\021ReleasePartitions\020\316\001\022\021\n\014ShowSe"
"gments\020\372\001\022\024\n\017DescribeSegment\020\373\001\022\021\n\014LoadS"
"egments\020\374\001\022\024\n\017ReleaseSegments\020\375\001\022\024\n\017Hand"
"offSegments\020\376\001\022\030\n\023LoadBalanceSegments\020\377\001"
"\022\025\n\020DescribeSegments\020\200\002\022\020\n\013CreateIndex\020\254"
"\002\022\022\n\rDescribeIndex\020\255\002\022\016\n\tDropIndex\020\256\002\022\013\n"
"\006Insert\020\220\003\022\013\n\006Delete\020\221\003\022\n\n\005Flush\020\222\003\022\027\n\022R"
"esendSegmentStats\020\223\003\022\013\n\006Upsert\020\224\003\022\013\n\006Sea"
"rch\020\364\003\022\021\n\014SearchResult\020\365\003\022\022\n\rGetIndexSta"
"te\020\366\003\022\032\n\025GetIndexBuildProgress\020\367\003\022\034\n\027Get"
"CollectionStatistics\020\370\003\022\033\n\026GetPartitionS"
"tatistics\020\371\003\022\r\n\010Retrieve\020\372\003\022\023\n\016RetrieveR"
"esult\020\373\003\022\024\n\017WatchDmChannels\020\374\003\022\025\n\020Remove"
"DmChannels\020\375\003\022\027\n\022WatchQueryChannels\020\376\003\022\030"
"\n\023RemoveQueryChannels\020\377\003\022\035\n\030SealedSegmen"
"tsChangeInfo\020\200\004\022\027\n\022WatchDeltaChannels\020\201\004"
"\022\024\n\017GetShardLeaders\020\202\004\022\020\n\013GetReplicas\020\203\004"
"\022\023\n\016UnsubDmChannel\020\204\004\022\024\n\017GetDistribution"
"\020\205\004\022\025\n\020SyncDistribution\020\206\004\022\020\n\013SegmentInf"
"o\020\330\004\022\017\n\nSystemInfo\020\331\004\022\024\n\017GetRecoveryInfo"
"\020\332\004\022\024\n\017GetSegmentState\020\333\004\022\r\n\010TimeTick\020\260\t"
"\022\023\n\016QueryNodeStats\020\261\t\022\016\n\tLoadIndex\020\262\t\022\016\n"
"\tRequestID\020\263\t\022\017\n\nRequestTSO\020\264\t\022\024\n\017Alloca"
"teSegment\020\265\t\022\026\n\021SegmentStatistics\020\266\t\022\025\n\020"
"SegmentFlushDone\020\267\t\022\017\n\nDataNodeTt\020\270\t\022\025\n\020"
"CreateCredential\020\334\013\022\022\n\rGetCredential\020\335\013\022"
"\025\n\020DeleteCredential\020\336\013\022\025\n\020UpdateCredenti"
"al\020\337\013\022\026\n\021ListCredUsernames\020\340\013\022\017\n\nCreateR"
"ole\020\300\014\022\r\n\010DropRole\020\301\014\022\024\n\017OperateUserRole"
"\020\302\014\022\017\n\nSelectRole\020\303\014\022\017\n\nSelectUser\020\304\014\022\023\n"
"\016SelectResource\020\305\014\022\025\n\020OperatePrivilege\020\306"
"\014\022\020\n\013SelectGrant\020\307\014\022\033\n\026RefreshPolicyInfo"
"Cache\020\310\014\022\017\n\nListPolicy\020\311\014\022\030\n\023CreateResou"
"rceGroup\020\244\r\022\026\n\021DropResourceGroup\020\245\r\022\027\n\022L"
"istResourceGroups\020\246\r\022\032\n\025DescribeResource"
"Group\020\247\r\022\021\n\014TransferNode\020\250\r\022\024\n\017TransferR"
"eplica\020\251\r*\"\n\007DslType\022\007\n\003Dsl\020\000\022\016\n\nBoolExp"
"rV1\020\001*B\n\017CompactionState\022\021\n\rUndefiedStat"
"e\020\000\022\r\n\tExecuting\020\001\022\r\n\tCompleted\020\002*X\n\020Con"
"sistencyLevel\022\n\n\006Strong\020\000\022\013\n\007Session\020\001\022\013"
"\n\007Bounded\020\002\022\016\n\nEventually\020\003\022\016\n\nCustomize"
"d\020\004*\236\001\n\013ImportState\022\021\n\rImportPending\020\000\022\020"
"\n\014ImportFailed\020\001\022\021\n\rImportStarted\020\002\022\023\n\017I"
"mportPersisted\020\005\022\021\n\rImportFlushed\020\010\022\023\n\017I"
"mportCompleted\020\006\022\032\n\026ImportFailedAndClean"
"ed\020\007*2\n\nObjectType\022\016\n\nCollection\020\000\022\n\n\006Gl"
"obal\020\001\022\010\n\004User\020\002*\227\007\n\017ObjectPrivilege\022\020\n\014"
"PrivilegeAll\020\000\022\035\n\031PrivilegeCreateCollect"
"ion\020\001\022\033\n\027PrivilegeDropCollection\020\002\022\037\n\033Pr"
"ivilegeDescribeCollection\020\003\022\034\n\030Privilege"
"ShowCollections\020\004\022\021\n\rPrivilegeLoad\020\005\022\024\n\020"
"PrivilegeRelease\020\006\022\027\n\023PrivilegeCompactio"
"n\020\007\022\023\n\017PrivilegeInsert\020\010\022\023\n\017PrivilegeDel"
"ete\020\t\022\032\n\026PrivilegeGetStatistics\020\n\022\030\n\024Pri"
"vilegeCreateIndex\020\013\022\030\n\024PrivilegeIndexDet"
"ail\020\014\022\026\n\022PrivilegeDropIndex\020\r\022\023\n\017Privile"
"geSearch\020\016\022\022\n\016PrivilegeFlush\020\017\022\022\n\016Privil"
"egeQuery\020\020\022\030\n\024PrivilegeLoadBalance\020\021\022\023\n\017"
"PrivilegeImport\020\022\022\034\n\030PrivilegeCreateOwne"
"rship\020\023\022\027\n\023PrivilegeUpdateUser\020\024\022\032\n\026Priv"
"ilegeDropOwnership\020\025\022\034\n\030PrivilegeSelectO"
"wnership\020\026\022\034\n\030PrivilegeManageOwnership\020\027"
"\022\027\n\023PrivilegeSelectUser\020\030\022\023\n\017PrivilegeUp"
"sert\020\031\022 \n\034PrivilegeCreateResourceGroup\020\032"
"\022\036\n\032PrivilegeDropResourceGroup\020\033\022\"\n\036Priv"
"ilegeDescribeResourceGroup\020\034\022\037\n\033Privileg"
"eListResourceGroups\020\035\022\031\n\025PrivilegeTransf"
"erNode\020\036\022\034\n\030PrivilegeTransferReplica\020\037\022\037"
"\n\033PrivilegeGetLoadingProgress\020 \022\031\n\025Privi"
"legeGetLoadState\020!*S\n\tStateCode\022\020\n\014Initi"
"alizing\020\000\022\013\n\007Healthy\020\001\022\014\n\010Abnormal\020\002\022\013\n\007"
"StandBy\020\003\022\014\n\010Stopping\020\004*c\n\tLoadState\022\025\n\021"
"LoadStateNotExist\020\000\022\024\n\020LoadStateNotLoad\020"
"\001\022\024\n\020LoadStateLoading\020\002\022\023\n\017LoadStateLoad"
"ed\020\003:^\n\021privilege_ext_obj\022\037.google.proto"
"buf.MessageOptions\030\351\007 \001(\0132!.milvus.proto"
".common.PrivilegeExtBf\n\016io.milvus.grpcB\013"
"CommonProtoP\001Z1github.com/milvus-io/milv"
"us-proto/go-api/commonpb\240\001\001\252\002\016IO.Milvus."
"Grpcb\006proto3"
"n.ErrorCode\022\016\n\006reason\030\002 \001(\t\022\014\n\004code\030\003 \001("
"\005\"*\n\014KeyValuePair\022\013\n\003key\030\001 \001(\t\022\r\n\005value\030"
"\002 \001(\t\"(\n\013KeyDataPair\022\013\n\003key\030\001 \001(\t\022\014\n\004dat"
"a\030\002 \001(\014\"\025\n\004Blob\022\r\n\005value\030\001 \001(\014\"c\n\020Placeh"
"olderValue\022\013\n\003tag\030\001 \001(\t\0222\n\004type\030\002 \001(\0162$."
"milvus.proto.common.PlaceholderType\022\016\n\006v"
"alues\030\003 \003(\014\"O\n\020PlaceholderGroup\022;\n\014place"
"holders\030\001 \003(\0132%.milvus.proto.common.Plac"
"eholderValue\"#\n\007Address\022\n\n\002ip\030\001 \001(\t\022\014\n\004p"
"ort\030\002 \001(\003\"\177\n\007MsgBase\022.\n\010msg_type\030\001 \001(\0162\034"
".milvus.proto.common.MsgType\022\r\n\005msgID\030\002 "
"\001(\003\022\021\n\ttimestamp\030\003 \001(\004\022\020\n\010sourceID\030\004 \001(\003"
"\022\020\n\010targetID\030\005 \001(\003\"7\n\tMsgHeader\022*\n\004base\030"
"\001 \001(\0132\034.milvus.proto.common.MsgBase\"M\n\014D"
"MLMsgHeader\022*\n\004base\030\001 \001(\0132\034.milvus.proto"
".common.MsgBase\022\021\n\tshardName\030\002 \001(\t\"\273\001\n\014P"
"rivilegeExt\0224\n\013object_type\030\001 \001(\0162\037.milvu"
"s.proto.common.ObjectType\022>\n\020object_priv"
"ilege\030\002 \001(\0162$.milvus.proto.common.Object"
"Privilege\022\031\n\021object_name_index\030\003 \001(\005\022\032\n\022"
"object_name_indexs\030\004 \001(\005\"2\n\014SegmentStats"
"\022\021\n\tSegmentID\030\001 \001(\003\022\017\n\007NumRows\030\002 \001(\003*\303\n\n"
"\tErrorCode\022\013\n\007Success\020\000\022\023\n\017UnexpectedErr"
"or\020\001\022\021\n\rConnectFailed\020\002\022\024\n\020PermissionDen"
"ied\020\003\022\027\n\023CollectionNotExists\020\004\022\023\n\017Illega"
"lArgument\020\005\022\024\n\020IllegalDimension\020\007\022\024\n\020Ill"
"egalIndexType\020\010\022\031\n\025IllegalCollectionName"
"\020\t\022\017\n\013IllegalTOPK\020\n\022\024\n\020IllegalRowRecord\020"
"\013\022\023\n\017IllegalVectorID\020\014\022\027\n\023IllegalSearchR"
"esult\020\r\022\020\n\014FileNotFound\020\016\022\016\n\nMetaFailed\020"
"\017\022\017\n\013CacheFailed\020\020\022\026\n\022CannotCreateFolder"
"\020\021\022\024\n\020CannotCreateFile\020\022\022\026\n\022CannotDelete"
"Folder\020\023\022\024\n\020CannotDeleteFile\020\024\022\023\n\017BuildI"
"ndexError\020\025\022\020\n\014IllegalNLIST\020\026\022\025\n\021Illegal"
"MetricType\020\027\022\017\n\013OutOfMemory\020\030\022\021\n\rIndexNo"
"tExist\020\031\022\023\n\017EmptyCollection\020\032\022\033\n\027UpdateI"
"mportTaskFailure\020\033\022\032\n\026CollectionNameNotF"
"ound\020\034\022\033\n\027CreateCredentialFailure\020\035\022\033\n\027U"
"pdateCredentialFailure\020\036\022\033\n\027DeleteCreden"
"tialFailure\020\037\022\030\n\024GetCredentialFailure\020 \022"
"\030\n\024ListCredUsersFailure\020!\022\022\n\016GetUserFail"
"ure\020\"\022\025\n\021CreateRoleFailure\020#\022\023\n\017DropRole"
"Failure\020$\022\032\n\026OperateUserRoleFailure\020%\022\025\n"
"\021SelectRoleFailure\020&\022\025\n\021SelectUserFailur"
"e\020\'\022\031\n\025SelectResourceFailure\020(\022\033\n\027Operat"
"ePrivilegeFailure\020)\022\026\n\022SelectGrantFailur"
"e\020*\022!\n\035RefreshPolicyInfoCacheFailure\020+\022\025"
"\n\021ListPolicyFailure\020,\022\022\n\016NotShardLeader\020"
"-\022\026\n\022NoReplicaAvailable\020.\022\023\n\017SegmentNotF"
"ound\020/\022\r\n\tForceDeny\0200\022\r\n\tRateLimit\0201\022\022\n\016"
"NodeIDNotMatch\0202\022\024\n\020UpsertAutoIDTrue\0203\022\034"
"\n\030InsufficientMemoryToLoad\0204\022\030\n\024MemoryQu"
"otaExhausted\0205\022\026\n\022DiskQuotaExhausted\0206\022\025"
"\n\021TimeTickLongDelay\0207\022\021\n\rNotReadyServe\0208"
"\022\033\n\027NotReadyCoordActivating\0209\022\017\n\013DataCoo"
"rdNA\020d\022\022\n\rDDRequestRace\020\350\007*c\n\nIndexState"
"\022\022\n\016IndexStateNone\020\000\022\014\n\010Unissued\020\001\022\016\n\nIn"
"Progress\020\002\022\014\n\010Finished\020\003\022\n\n\006Failed\020\004\022\t\n\005"
"Retry\020\005*\202\001\n\014SegmentState\022\024\n\020SegmentState"
"None\020\000\022\014\n\010NotExist\020\001\022\013\n\007Growing\020\002\022\n\n\006Sea"
"led\020\003\022\013\n\007Flushed\020\004\022\014\n\010Flushing\020\005\022\013\n\007Drop"
"ped\020\006\022\r\n\tImporting\020\007*>\n\017PlaceholderType\022"
"\010\n\004None\020\000\022\020\n\014BinaryVector\020d\022\017\n\013FloatVect"
"or\020e*\300\016\n\007MsgType\022\r\n\tUndefined\020\000\022\024\n\020Creat"
"eCollection\020d\022\022\n\016DropCollection\020e\022\021\n\rHas"
"Collection\020f\022\026\n\022DescribeCollection\020g\022\023\n\017"
"ShowCollections\020h\022\024\n\020GetSystemConfigs\020i\022"
"\022\n\016LoadCollection\020j\022\025\n\021ReleaseCollection"
"\020k\022\017\n\013CreateAlias\020l\022\r\n\tDropAlias\020m\022\016\n\nAl"
"terAlias\020n\022\023\n\017AlterCollection\020o\022\024\n\020Renam"
"eCollection\020p\022\024\n\017CreatePartition\020\310\001\022\022\n\rD"
"ropPartition\020\311\001\022\021\n\014HasPartition\020\312\001\022\026\n\021De"
"scribePartition\020\313\001\022\023\n\016ShowPartitions\020\314\001\022"
"\023\n\016LoadPartitions\020\315\001\022\026\n\021ReleasePartition"
"s\020\316\001\022\021\n\014ShowSegments\020\372\001\022\024\n\017DescribeSegme"
"nt\020\373\001\022\021\n\014LoadSegments\020\374\001\022\024\n\017ReleaseSegme"
"nts\020\375\001\022\024\n\017HandoffSegments\020\376\001\022\030\n\023LoadBala"
"nceSegments\020\377\001\022\025\n\020DescribeSegments\020\200\002\022\020\n"
"\013CreateIndex\020\254\002\022\022\n\rDescribeIndex\020\255\002\022\016\n\tD"
"ropIndex\020\256\002\022\013\n\006Insert\020\220\003\022\013\n\006Delete\020\221\003\022\n\n"
"\005Flush\020\222\003\022\027\n\022ResendSegmentStats\020\223\003\022\013\n\006Up"
"sert\020\224\003\022\013\n\006Search\020\364\003\022\021\n\014SearchResult\020\365\003\022"
"\022\n\rGetIndexState\020\366\003\022\032\n\025GetIndexBuildProg"
"ress\020\367\003\022\034\n\027GetCollectionStatistics\020\370\003\022\033\n"
"\026GetPartitionStatistics\020\371\003\022\r\n\010Retrieve\020\372"
"\003\022\023\n\016RetrieveResult\020\373\003\022\024\n\017WatchDmChannel"
"s\020\374\003\022\025\n\020RemoveDmChannels\020\375\003\022\027\n\022WatchQuer"
"yChannels\020\376\003\022\030\n\023RemoveQueryChannels\020\377\003\022\035"
"\n\030SealedSegmentsChangeInfo\020\200\004\022\027\n\022WatchDe"
"ltaChannels\020\201\004\022\024\n\017GetShardLeaders\020\202\004\022\020\n\013"
"GetReplicas\020\203\004\022\023\n\016UnsubDmChannel\020\204\004\022\024\n\017G"
"etDistribution\020\205\004\022\025\n\020SyncDistribution\020\206\004"
"\022\020\n\013SegmentInfo\020\330\004\022\017\n\nSystemInfo\020\331\004\022\024\n\017G"
"etRecoveryInfo\020\332\004\022\024\n\017GetSegmentState\020\333\004\022"
"\r\n\010TimeTick\020\260\t\022\023\n\016QueryNodeStats\020\261\t\022\016\n\tL"
"oadIndex\020\262\t\022\016\n\tRequestID\020\263\t\022\017\n\nRequestTS"
"O\020\264\t\022\024\n\017AllocateSegment\020\265\t\022\026\n\021SegmentSta"
"tistics\020\266\t\022\025\n\020SegmentFlushDone\020\267\t\022\017\n\nDat"
"aNodeTt\020\270\t\022\025\n\020CreateCredential\020\334\013\022\022\n\rGet"
"Credential\020\335\013\022\025\n\020DeleteCredential\020\336\013\022\025\n\020"
"UpdateCredential\020\337\013\022\026\n\021ListCredUsernames"
"\020\340\013\022\017\n\nCreateRole\020\300\014\022\r\n\010DropRole\020\301\014\022\024\n\017O"
"perateUserRole\020\302\014\022\017\n\nSelectRole\020\303\014\022\017\n\nSe"
"lectUser\020\304\014\022\023\n\016SelectResource\020\305\014\022\025\n\020Oper"
"atePrivilege\020\306\014\022\020\n\013SelectGrant\020\307\014\022\033\n\026Ref"
"reshPolicyInfoCache\020\310\014\022\017\n\nListPolicy\020\311\014\022"
"\030\n\023CreateResourceGroup\020\244\r\022\026\n\021DropResourc"
"eGroup\020\245\r\022\027\n\022ListResourceGroups\020\246\r\022\032\n\025De"
"scribeResourceGroup\020\247\r\022\021\n\014TransferNode\020\250"
"\r\022\024\n\017TransferReplica\020\251\r*\"\n\007DslType\022\007\n\003Ds"
"l\020\000\022\016\n\nBoolExprV1\020\001*B\n\017CompactionState\022\021"
"\n\rUndefiedState\020\000\022\r\n\tExecuting\020\001\022\r\n\tComp"
"leted\020\002*X\n\020ConsistencyLevel\022\n\n\006Strong\020\000\022"
"\013\n\007Session\020\001\022\013\n\007Bounded\020\002\022\016\n\nEventually\020"
"\003\022\016\n\nCustomized\020\004*\236\001\n\013ImportState\022\021\n\rImp"
"ortPending\020\000\022\020\n\014ImportFailed\020\001\022\021\n\rImport"
"Started\020\002\022\023\n\017ImportPersisted\020\005\022\021\n\rImport"
"Flushed\020\010\022\023\n\017ImportCompleted\020\006\022\032\n\026Import"
"FailedAndCleaned\020\007*2\n\nObjectType\022\016\n\nColl"
"ection\020\000\022\n\n\006Global\020\001\022\010\n\004User\020\002*\227\007\n\017Objec"
"tPrivilege\022\020\n\014PrivilegeAll\020\000\022\035\n\031Privileg"
"eCreateCollection\020\001\022\033\n\027PrivilegeDropColl"
"ection\020\002\022\037\n\033PrivilegeDescribeCollection\020"
"\003\022\034\n\030PrivilegeShowCollections\020\004\022\021\n\rPrivi"
"legeLoad\020\005\022\024\n\020PrivilegeRelease\020\006\022\027\n\023Priv"
"ilegeCompaction\020\007\022\023\n\017PrivilegeInsert\020\010\022\023"
"\n\017PrivilegeDelete\020\t\022\032\n\026PrivilegeGetStati"
"stics\020\n\022\030\n\024PrivilegeCreateIndex\020\013\022\030\n\024Pri"
"vilegeIndexDetail\020\014\022\026\n\022PrivilegeDropInde"
"x\020\r\022\023\n\017PrivilegeSearch\020\016\022\022\n\016PrivilegeFlu"
"sh\020\017\022\022\n\016PrivilegeQuery\020\020\022\030\n\024PrivilegeLoa"
"dBalance\020\021\022\023\n\017PrivilegeImport\020\022\022\034\n\030Privi"
"legeCreateOwnership\020\023\022\027\n\023PrivilegeUpdate"
"User\020\024\022\032\n\026PrivilegeDropOwnership\020\025\022\034\n\030Pr"
"ivilegeSelectOwnership\020\026\022\034\n\030PrivilegeMan"
"ageOwnership\020\027\022\027\n\023PrivilegeSelectUser\020\030\022"
"\023\n\017PrivilegeUpsert\020\031\022 \n\034PrivilegeCreateR"
"esourceGroup\020\032\022\036\n\032PrivilegeDropResourceG"
"roup\020\033\022\"\n\036PrivilegeDescribeResourceGroup"
"\020\034\022\037\n\033PrivilegeListResourceGroups\020\035\022\031\n\025P"
"rivilegeTransferNode\020\036\022\034\n\030PrivilegeTrans"
"ferReplica\020\037\022\037\n\033PrivilegeGetLoadingProgr"
"ess\020 \022\031\n\025PrivilegeGetLoadState\020!*S\n\tStat"
"eCode\022\020\n\014Initializing\020\000\022\013\n\007Healthy\020\001\022\014\n\010"
"Abnormal\020\002\022\013\n\007StandBy\020\003\022\014\n\010Stopping\020\004*c\n"
"\tLoadState\022\025\n\021LoadStateNotExist\020\000\022\024\n\020Loa"
"dStateNotLoad\020\001\022\024\n\020LoadStateLoading\020\002\022\023\n"
"\017LoadStateLoaded\020\003:^\n\021privilege_ext_obj\022"
"\037.google.protobuf.MessageOptions\030\351\007 \001(\0132"
"!.milvus.proto.common.PrivilegeExtBf\n\016io"
".milvus.grpcB\013CommonProtoP\001Z1github.com/"
"milvus-io/milvus-proto/go-api/commonpb\240\001"
"\001\252\002\016IO.Milvus.Grpcb\006proto3"
;
static const ::_pbi::DescriptorTable* const descriptor_table_common_2eproto_deps[1] = {
&::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto,
};
static ::_pbi::once_flag descriptor_table_common_2eproto_once;
const ::_pbi::DescriptorTable descriptor_table_common_2eproto = {
false, false, 6212, descriptor_table_protodef_common_2eproto,
false, false, 6226, descriptor_table_protodef_common_2eproto,
"common.proto",
&descriptor_table_common_2eproto_once, descriptor_table_common_2eproto_deps, 1, 12,
schemas, file_default_instances, TableStruct_common_2eproto::offsets,
@ -914,6 +916,7 @@ Status::Status(const Status& from)
new (&_impl_) Impl_{
decltype(_impl_.reason_){}
, decltype(_impl_.error_code_){}
, decltype(_impl_.code_){}
, /*decltype(_impl_._cached_size_)*/{}};
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
@ -925,7 +928,9 @@ Status::Status(const Status& from)
_this->_impl_.reason_.Set(from._internal_reason(),
_this->GetArenaForAllocation());
}
_this->_impl_.error_code_ = from._impl_.error_code_;
::memcpy(&_impl_.error_code_, &from._impl_.error_code_,
static_cast<size_t>(reinterpret_cast<char*>(&_impl_.code_) -
reinterpret_cast<char*>(&_impl_.error_code_)) + sizeof(_impl_.code_));
// @@protoc_insertion_point(copy_constructor:milvus.proto.common.Status)
}
@ -936,6 +941,7 @@ inline void Status::SharedCtor(
new (&_impl_) Impl_{
decltype(_impl_.reason_){}
, decltype(_impl_.error_code_){0}
, decltype(_impl_.code_){0}
, /*decltype(_impl_._cached_size_)*/{}
};
_impl_.reason_.InitDefault();
@ -969,7 +975,9 @@ void Status::Clear() {
(void) cached_has_bits;
_impl_.reason_.ClearToEmpty();
_impl_.error_code_ = 0;
::memset(&_impl_.error_code_, 0, static_cast<size_t>(
reinterpret_cast<char*>(&_impl_.code_) -
reinterpret_cast<char*>(&_impl_.error_code_)) + sizeof(_impl_.code_));
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
@ -998,6 +1006,14 @@ const char* Status::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
} else
goto handle_unusual;
continue;
// int32 code = 3;
case 3:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 24)) {
_impl_.code_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
} else
goto handle_unusual;
continue;
default:
goto handle_unusual;
} // switch
@ -1044,6 +1060,12 @@ uint8_t* Status::_InternalSerialize(
2, this->_internal_reason(), target);
}
// int32 code = 3;
if (this->_internal_code() != 0) {
target = stream->EnsureSpace(target);
target = ::_pbi::WireFormatLite::WriteInt32ToArray(3, this->_internal_code(), target);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream);
@ -1073,6 +1095,11 @@ size_t Status::ByteSizeLong() const {
::_pbi::WireFormatLite::EnumSize(this->_internal_error_code());
}
// int32 code = 3;
if (this->_internal_code() != 0) {
total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_code());
}
return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_);
}
@ -1097,6 +1124,9 @@ void Status::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBU
if (from._internal_error_code() != 0) {
_this->_internal_set_error_code(from._internal_error_code());
}
if (from._internal_code() != 0) {
_this->_internal_set_code(from._internal_code());
}
_this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
}
@ -1120,7 +1150,12 @@ void Status::InternalSwap(Status* other) {
&_impl_.reason_, lhs_arena,
&other->_impl_.reason_, rhs_arena
);
swap(_impl_.error_code_, other->_impl_.error_code_);
::PROTOBUF_NAMESPACE_ID::internal::memswap<
PROTOBUF_FIELD_OFFSET(Status, _impl_.code_)
+ sizeof(Status::_impl_.code_)
- PROTOBUF_FIELD_OFFSET(Status, _impl_.error_code_)>(
reinterpret_cast<char*>(&_impl_.error_code_),
reinterpret_cast<char*>(&other->_impl_.error_code_));
}
::PROTOBUF_NAMESPACE_ID::Metadata Status::GetMetadata() const {

View File

@ -758,6 +758,7 @@ class Status final :
enum : int {
kReasonFieldNumber = 2,
kErrorCodeFieldNumber = 1,
kCodeFieldNumber = 3,
};
// string reason = 2;
void clear_reason();
@ -782,6 +783,15 @@ class Status final :
void _internal_set_error_code(::milvus::proto::common::ErrorCode value);
public:
// int32 code = 3;
void clear_code();
int32_t code() const;
void set_code(int32_t value);
private:
int32_t _internal_code() const;
void _internal_set_code(int32_t value);
public:
// @@protoc_insertion_point(class_scope:milvus.proto.common.Status)
private:
class _Internal;
@ -792,6 +802,7 @@ class Status final :
struct Impl_ {
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr reason_;
int error_code_;
int32_t code_;
mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_;
};
union { Impl_ _impl_; };
@ -2746,6 +2757,26 @@ inline void Status::set_allocated_reason(std::string* reason) {
// @@protoc_insertion_point(field_set_allocated:milvus.proto.common.Status.reason)
}
// int32 code = 3;
inline void Status::clear_code() {
_impl_.code_ = 0;
}
inline int32_t Status::_internal_code() const {
return _impl_.code_;
}
inline int32_t Status::code() const {
// @@protoc_insertion_point(field_get:milvus.proto.common.Status.code)
return _internal_code();
}
inline void Status::_internal_set_code(int32_t value) {
_impl_.code_ = value;
}
inline void Status::set_code(int32_t value) {
_internal_set_code(value);
// @@protoc_insertion_point(field_set:milvus.proto.common.Status.code)
}
// -------------------------------------------------------------------
// KeyValuePair

View File

@ -18,8 +18,6 @@
package merr
import (
"context"
"github.com/cockroachdb/errors"
"github.com/samber/lo"
@ -153,29 +151,6 @@ func (e milvusError) Is(err error) bool {
return false
}
// Code returns the error code of the given error,
// WARN: DO NOT use this for now
func Code(err error) int32 {
if err == nil {
return 0
}
cause := errors.Cause(err)
switch cause := cause.(type) {
case milvusError:
return cause.code()
default:
if errors.Is(cause, context.Canceled) {
return CanceledCode
} else if errors.Is(cause, context.DeadlineExceeded) {
return TimeoutCode
} else {
return errUnexpected.code()
}
}
}
type multiErrors struct {
errs []error
}

View File

@ -46,6 +46,16 @@ func (s *ErrSuite) TestCode() {
s.True(sameCodeErr.Is(ErrCollectionNotFound))
}
func (s *ErrSuite) TestStatus() {
err := WrapErrCollectionNotFound(1)
status := Status(err)
restoredErr := Error(status)
s.ErrorIs(err, restoredErr)
s.Equal(int32(0), Status(nil).Code)
s.Nil(Error(successStatus))
}
func (s *ErrSuite) TestWrap() {
// Service related
s.ErrorIs(WrapErrServiceNotReady("init", "test init..."), ErrServiceNotReady)

View File

@ -18,15 +18,68 @@
package merr
import (
"context"
"strings"
"github.com/cockroachdb/errors"
"github.com/milvus-io/milvus-proto/go-api/commonpb"
)
// Declare a success status, avoid create it every time
var successStatus = &commonpb.Status{}
// Code returns the error code of the given error,
// WARN: DO NOT use this for now
func Code(err error) int32 {
if err == nil {
return 0
}
cause := errors.Cause(err)
switch cause := cause.(type) {
case milvusError:
return cause.code()
default:
if errors.Is(cause, context.Canceled) {
return CanceledCode
} else if errors.Is(cause, context.DeadlineExceeded) {
return TimeoutCode
} else {
return errUnexpected.code()
}
}
}
func IsRetriable(err error) bool {
return Code(err)&retriableFlag != 0
}
// Status returns a status according to the given err,
// returns Success status if err is nil
func Status(err error) *commonpb.Status {
if err == nil {
return successStatus
}
return &commonpb.Status{
Code: Code(err),
Reason: err.Error(),
// Deprecated, for compatibility, set it to UnexpectedError
ErrorCode: commonpb.ErrorCode_UnexpectedError,
}
}
// Error returns a error according to the given status,
// returns nil if the status is a success status
func Error(status *commonpb.Status) error {
if status.Code == 0 {
return nil
}
return newMilvusError(status.GetReason(), status.Code, status.Code&retriableFlag != 0)
}
// Service related
func WrapErrServiceNotReady(stage string, msg ...string) error {
err := errors.Wrapf(ErrServiceNotReady, "stage=%s", stage)