mirror of
https://github.com/psviderski/uncloud.git
synced 2026-10-08 14:14:52 +00:00
chore: init scheduler entities
This commit is contained in:
1 parent
7705db2c4f
commit
000a8a1d3e
3 files changed
+138
No files matched your search
@@ -0,0 +1,37 @@
|
||||
package scheduler
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/psviderski/uncloud/pkg/api"
|
||||
)
|
||||
|
||||
// Constraint is the base interface for all scheduling constraints.
|
||||
type Constraint interface {
|
||||
// Evaluate determines if a machine satisfies the constraint.
|
||||
Evaluate(machine *Machine) bool
|
||||
|
||||
// Description returns a human-readable description of the constraint.
|
||||
Description() string
|
||||
}
|
||||
|
||||
func constraintsFromSpec(spec api.ServiceSpec) []Constraint {
|
||||
return []Constraint{}
|
||||
}
|
||||
|
||||
type PlacementConstraint struct {
|
||||
Machines []string
|
||||
}
|
||||
|
||||
func (c *PlacementConstraint) Evaluate(machine *Machine) bool {
|
||||
for _, nameOrID := range c.Machines {
|
||||
if machine.Info.Id == nameOrID || machine.Info.Name == nameOrID {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (c *PlacementConstraint) Description() string {
|
||||
return "Placement constraint by machines: " + strings.Join(c.Machines, ", ")
|
||||
}
|
||||
Reference in new issue
Block a user