github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/client/interfaces/client.go (about)

     1  package interfaces
     2  
     3  import (
     4  	"github.com/hashicorp/nomad/nomad/structs"
     5  	"github.com/hashicorp/nomad/plugins/device"
     6  )
     7  
     8  type Client interface {
     9  	AllocStateHandler
    10  }
    11  
    12  // AllocStateHandler exposes a handler to be called when an allocation's state changes
    13  type AllocStateHandler interface {
    14  	// AllocStateUpdated is used to emit an updated allocation. This allocation
    15  	// is stripped to only include client settable fields.
    16  	AllocStateUpdated(alloc *structs.Allocation)
    17  
    18  	// PutAllocation is used to persist an updated allocation in the local state store.
    19  	PutAllocation(*structs.Allocation) error
    20  }
    21  
    22  // DeviceStatsReporter gives access to the latest resource usage
    23  // for devices
    24  type DeviceStatsReporter interface {
    25  	LatestDeviceResourceStats([]*structs.AllocatedDeviceResource) []*device.DeviceGroupStats
    26  }
    27  
    28  // EnvReplacer is an interface which can interpolate environment variables and
    29  // is usually satisfied by taskenv.TaskEnv.
    30  type EnvReplacer interface {
    31  	ReplaceEnv(string) string
    32  	ClientPath(string, bool) (string, bool)
    33  }
    34  
    35  // ArtifactGetter is an interface satisfied by the getter package.
    36  type ArtifactGetter interface {
    37  	// Get artifact and put it in the task directory.
    38  	Get(taskEnv EnvReplacer, artifact *structs.TaskArtifact) error
    39  }