2018-07-19 00:06:44 +00:00
|
|
|
package interfaces
|
|
|
|
|
2018-11-15 15:13:14 +00:00
|
|
|
import (
|
|
|
|
"github.com/hashicorp/nomad/nomad/structs"
|
|
|
|
"github.com/hashicorp/nomad/plugins/device"
|
|
|
|
)
|
2018-07-19 00:06:44 +00:00
|
|
|
|
|
|
|
type Client interface {
|
|
|
|
AllocStateHandler
|
|
|
|
}
|
|
|
|
|
2022-01-10 16:59:46 +00:00
|
|
|
// AllocStateHandler exposes a handler to be called when an allocation's state changes
|
2018-07-19 00:06:44 +00:00
|
|
|
type AllocStateHandler interface {
|
|
|
|
// AllocStateUpdated is used to emit an updated allocation. This allocation
|
|
|
|
// is stripped to only include client settable fields.
|
2018-08-17 17:34:44 +00:00
|
|
|
AllocStateUpdated(alloc *structs.Allocation)
|
2022-03-02 10:47:26 +00:00
|
|
|
|
|
|
|
// PutAllocation is used to persist an updated allocation in the local state store.
|
|
|
|
PutAllocation(*structs.Allocation) error
|
2018-07-19 00:06:44 +00:00
|
|
|
}
|
2018-11-15 15:13:14 +00:00
|
|
|
|
|
|
|
// DeviceStatsReporter gives access to the latest resource usage
|
|
|
|
// for devices
|
|
|
|
type DeviceStatsReporter interface {
|
|
|
|
LatestDeviceResourceStats([]*structs.AllocatedDeviceResource) []*device.DeviceGroupStats
|
|
|
|
}
|
2022-05-03 22:38:32 +00:00
|
|
|
|
|
|
|
// EnvReplacer is an interface which can interpolate environment variables and
|
|
|
|
// is usually satisfied by taskenv.TaskEnv.
|
|
|
|
type EnvReplacer interface {
|
|
|
|
ReplaceEnv(string) string
|
|
|
|
ClientPath(string, bool) (string, bool)
|
|
|
|
}
|
|
|
|
|
|
|
|
// ArtifactGetter is an interface satisfied by the helper/getter package.
|
|
|
|
type ArtifactGetter interface {
|
|
|
|
GetArtifact(taskEnv EnvReplacer, artifact *structs.TaskArtifact) error
|
|
|
|
}
|