@@ -95,6 +95,12 @@ pub enum Feature {
9595 Unknown ,
9696}
9797
98+ pub enum VerifyResult {
99+ MissMatch ,
100+ Success ,
101+ Failure ,
102+ }
103+
98104impl fmt:: Display for Feature {
99105 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
100106 match self {
@@ -159,34 +165,40 @@ impl Feature {
159165 }
160166 }
161167
162- pub fn verify ( & self , feature : & Feature ) -> Result < bool , ErrorCode > {
168+ pub fn verify ( & self , feature : & Feature ) -> Result < VerifyResult , ErrorCode > {
163169 match ( self , feature) {
164170 ( Feature :: ComputeQuota ( c) , Feature :: ComputeQuota ( v) ) => {
165171 if let Some ( thread_num) = c. threads_num {
166172 if thread_num <= v. threads_num . unwrap_or ( usize:: MAX ) {
167- return Ok ( false ) ;
173+ return Ok ( VerifyResult :: Failure ) ;
168174 }
169175 }
170176
171177 if let Some ( max_memory_usage) = c. memory_usage {
172178 if max_memory_usage <= v. memory_usage . unwrap_or ( usize:: MAX ) {
173- return Ok ( false ) ;
179+ return Ok ( VerifyResult :: Failure ) ;
174180 }
175181 }
176182
177- Ok ( true )
183+ Ok ( VerifyResult :: Success )
178184 }
179185 ( Feature :: StorageQuota ( c) , Feature :: StorageQuota ( v) ) => {
180186 if let Some ( max_storage_usage) = c. storage_usage {
181187 if max_storage_usage <= v. storage_usage . unwrap_or ( usize:: MAX ) {
182- return Ok ( false ) ;
188+ return Ok ( VerifyResult :: Failure ) ;
183189 }
184190 }
185191
186- Ok ( true )
192+ Ok ( VerifyResult :: Success )
187193 }
188- ( Feature :: MaxCpuQuota ( c) , Feature :: MaxCpuQuota ( v) ) => Ok ( c > v) ,
189- ( Feature :: MaxNodeQuota ( c) , Feature :: MaxNodeQuota ( v) ) => Ok ( c > v) ,
194+ ( Feature :: MaxCpuQuota ( c) , Feature :: MaxCpuQuota ( v) ) => match c > v {
195+ true => Ok ( VerifyResult :: Success ) ,
196+ false => Ok ( VerifyResult :: Failure ) ,
197+ } ,
198+ ( Feature :: MaxNodeQuota ( c) , Feature :: MaxNodeQuota ( v) ) => match c > v {
199+ true => Ok ( VerifyResult :: Success ) ,
200+ false => Ok ( VerifyResult :: Failure ) ,
201+ } ,
190202 ( Feature :: Test , Feature :: Test )
191203 | ( Feature :: AggregateIndex , Feature :: AggregateIndex )
192204 | ( Feature :: ComputedColumn , Feature :: ComputedColumn )
@@ -201,8 +213,8 @@ impl Feature {
201213 | ( Feature :: StorageEncryption , Feature :: StorageEncryption )
202214 | ( Feature :: HilbertClustering , Feature :: HilbertClustering )
203215 | ( Feature :: NgramIndex , Feature :: NgramIndex )
204- | ( Feature :: VectorIndex , Feature :: VectorIndex ) => Ok ( true ) ,
205- ( _, _) => Ok ( false ) ,
216+ | ( Feature :: VectorIndex , Feature :: VectorIndex ) => Ok ( VerifyResult :: Success ) ,
217+ ( _, _) => Ok ( VerifyResult :: MissMatch ) ,
206218 }
207219 }
208220}
0 commit comments