package models import ( "fmt" "model-engine/db" ) type Model interface { Init(task *db.ModelTask) error Run() error Shutdown() error } var modelRegistry = map[string]func() Model{ "gather": func() Model { return &GatherModel{} }, // 添加其他模型 } func GetModel(modelID string) (Model, error) { if factory, exists := modelRegistry[modelID]; exists { return factory(), nil } return nil, fmt.Errorf("model %s not found", modelID) }