db: check funcs required by dispatcher

This commit is contained in:
Yousong Zhou
2020-11-26 21:18:57 +08:00
parent 97dbd1899f
commit 805002005f
+35
View File
@@ -17,6 +17,7 @@ package db
import (
"fmt"
"os"
"reflect"
"yunion.io/x/log"
"yunion.io/x/pkg/utils"
@@ -74,6 +75,40 @@ func mustCheckModelManager(modelMan IModelManager) {
}
}
}
if false {
requiredManagerFuncNames := []string{
"ListItemFilter",
"OrderByExtraFields",
"FetchCustomizeColumns",
}
for _, name := range requiredManagerFuncNames {
manV := reflect.ValueOf(modelMan)
methV := manV.MethodByName(name)
if !methV.IsValid() {
msg := fmt.Sprintf("model manager %T: has no valid %s, likely caused by ambiguity",
modelMan, name)
panic(msg)
}
}
requiredModelFuncNames := []string{
"GetExtraDetails",
}
for _, name := range requiredModelFuncNames {
model, err := NewModelObject(modelMan)
if err != nil {
msg := fmt.Sprintf("model manager %T: new model object: %v", modelMan, err)
panic(msg)
}
modelV := reflect.ValueOf(model)
methV := modelV.MethodByName(name)
if !methV.IsValid() {
msg := fmt.Sprintf("model %T: has no valid %s, likely caused by ambiguity",
model, name)
panic(msg)
}
}
}
}
func CheckSync(autoSync bool) bool {