2018-06-22 00:35:07 +00:00
|
|
|
package interfaces
|
|
|
|
|
2018-07-18 20:45:55 +00:00
|
|
|
import (
|
2018-10-04 23:22:01 +00:00
|
|
|
"github.com/hashicorp/nomad/client/allocrunner/state"
|
2018-10-04 22:45:46 +00:00
|
|
|
cstructs "github.com/hashicorp/nomad/client/structs"
|
2018-07-18 20:45:55 +00:00
|
|
|
)
|
2018-06-22 00:35:07 +00:00
|
|
|
|
|
|
|
// AllocRunner is the interface for an allocation runner.
|
|
|
|
type AllocRunner interface {
|
|
|
|
// ID returns the ID of the allocation being run.
|
|
|
|
ID() string
|
|
|
|
|
|
|
|
// Run starts the runner and begins executing all the tasks as part of the
|
|
|
|
// allocation.
|
|
|
|
Run()
|
|
|
|
|
|
|
|
// State returns a copy of the runners state object
|
|
|
|
State() *state.State
|
2018-07-18 20:45:55 +00:00
|
|
|
|
|
|
|
TaskStateHandler
|
2018-06-22 00:35:07 +00:00
|
|
|
}
|
|
|
|
|
2018-07-18 20:45:55 +00:00
|
|
|
// TaskStateHandler exposes a handler to be called when a task's state changes
|
|
|
|
type TaskStateHandler interface {
|
2018-10-16 03:38:12 +00:00
|
|
|
// TaskStateUpdated is used to notify the alloc runner about task state
|
|
|
|
// changes.
|
|
|
|
TaskStateUpdated()
|
2018-06-22 00:35:07 +00:00
|
|
|
}
|
2018-10-04 22:45:46 +00:00
|
|
|
|
|
|
|
// AllocStatsReporter gives acess to the latest resource usage from the
|
|
|
|
// allocation
|
|
|
|
type AllocStatsReporter interface {
|
|
|
|
LatestAllocStats(taskFilter string) (*cstructs.AllocResourceUsage, error)
|
|
|
|
}
|