Refactor backend options handling and validation

This commit is contained in:
2025-10-19 17:41:08 +02:00
parent 2a7010d0e1
commit 55f671c354
10 changed files with 480 additions and 425 deletions

View File

@@ -1,5 +1,10 @@
package backends
import (
"fmt"
"llamactl/pkg/validation"
)
type MlxServerOptions struct {
// Basic connection options
Model string `json:"model,omitempty"`
@@ -50,3 +55,21 @@ func ParseMlxCommand(command string) (*MlxServerOptions, error) {
return &mlxOptions, nil
}
// validateMlxOptions validates MLX backend specific options
func validateMlxOptions(options *MlxServerOptions) error {
if options == nil {
return validation.ValidationError(fmt.Errorf("MLX server options cannot be nil for MLX backend"))
}
if err := validation.ValidateStructStrings(options, ""); err != nil {
return err
}
// Basic network validation for port
if options.Port < 0 || options.Port > 65535 {
return validation.ValidationError(fmt.Errorf("invalid port range: %d", options.Port))
}
return nil
}