package models import "time" // Backend ist eine Pool-Definition (Name, Scheme, Healthcheck, LB-Algo). // Die konkreten Upstream-Server leben in BackendServer (1:N). type Backend struct { ID int64 `gorm:"primaryKey" json:"id"` Name string `gorm:"column:name;uniqueIndex" json:"name"` Scheme string `gorm:"column:scheme" json:"scheme"` HealthCheckPath *string `gorm:"column:health_check_path" json:"health_check_path,omitempty"` LBAlgorithm string `gorm:"column:lb_algorithm" json:"lb_algorithm"` Active bool `gorm:"column:active" json:"active"` CreatedAt time.Time `gorm:"column:created_at" json:"created_at"` UpdatedAt time.Time `gorm:"column:updated_at" json:"updated_at"` } func (Backend) TableName() string { return "backends" } // BackendServer ist ein konkreter Upstream im Pool. weight steuert das // LB-Verhältnis (roundrobin/leastconn); backup wird nur bedient wenn // alle non-backup-Server down sind. type BackendServer struct { ID int64 `gorm:"primaryKey" json:"id"` BackendID int64 `gorm:"column:backend_id" json:"backend_id"` Name string `gorm:"column:name" json:"name"` Address string `gorm:"column:address" json:"address"` Port int `gorm:"column:port" json:"port"` Weight int `gorm:"column:weight" json:"weight"` Backup bool `gorm:"column:backup" json:"backup"` Active bool `gorm:"column:active" json:"active"` CreatedAt time.Time `gorm:"column:created_at" json:"created_at"` UpdatedAt time.Time `gorm:"column:updated_at" json:"updated_at"` } func (BackendServer) TableName() string { return "backend_servers" }