Moved schedulers from the main programs to schedulers package. Can now choose different scheduelrs to use. Work on code sharing between schedulers remains to be done.
This commit is contained in:
parent
407c350d3c
commit
c2e2b7e554
9 changed files with 575 additions and 323 deletions
8
def/metric.go
Normal file
8
def/metric.go
Normal file
|
@ -0,0 +1,8 @@
|
|||
package def
|
||||
|
||||
type Metric struct {
|
||||
Name string `json:"name"`
|
||||
CPU float64 `json:"cpu"`
|
||||
RAM float64 `json:"ram"`
|
||||
Watts float64 `json:"watts"`
|
||||
}
|
35
def/task.go
Normal file
35
def/task.go
Normal file
|
@ -0,0 +1,35 @@
|
|||
package def
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/pkg/errors"
|
||||
"os"
|
||||
)
|
||||
|
||||
type Task struct {
|
||||
Name string `json:"name"`
|
||||
CPU float64 `json:"cpu"`
|
||||
RAM float64 `json:"ram"`
|
||||
Watts float64 `json:"watts"`
|
||||
Image string `json:"image"`
|
||||
CMD string `json:"cmd"`
|
||||
Instances *int `json:"inst"`
|
||||
Host string `json:"host"`
|
||||
}
|
||||
|
||||
func TasksFromJSON(uri string) ([]Task, error) {
|
||||
|
||||
var tasks []Task
|
||||
|
||||
file, err := os.Open(uri)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "Error opening file")
|
||||
}
|
||||
|
||||
err = json.NewDecoder(file).Decode(&tasks)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "Error unmarshalling")
|
||||
}
|
||||
|
||||
return tasks, nil
|
||||
}
|
Reference in a new issue