interfaces

package
v0.9.0-beta2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 30, 2019 License: MPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AllocRunner

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

	TaskStateHandler
}

AllocRunner is the interface for an allocation runner.

type AllocStatsReporter

type AllocStatsReporter interface {
	LatestAllocStats(taskFilter string) (*cstructs.AllocResourceUsage, error)
}

AllocStatsReporter gives acess to the latest resource usage from the allocation

type DriverStats

type DriverStats interface {
	Stats(context.Context, time.Duration) (<-chan *cstructs.TaskResourceUsage, error)
}

DriverStats is the interface implemented by DriverHandles to return task stats.

type HookTarget

type HookTarget interface {
	// State retrieves a copy of the target alloc runners state.
	State() *state.State
}

type RunnerDestroyHook

type RunnerDestroyHook interface {
	RunnerHook
	Destroy() error
}

type RunnerHook

type RunnerHook interface {
	Name() string
}

RunnnerHook is a lifecycle hook into the life cycle of an allocation runner.

type RunnerHookFactory

type RunnerHookFactory func(target HookTarget) (RunnerHook, error)

XXX Not sure yet

type RunnerPostrunHook

type RunnerPostrunHook interface {
	RunnerHook
	Postrun() error
}

type RunnerPrerunHook

type RunnerPrerunHook interface {
	RunnerHook
	Prerun(context.Context) error
}

type RunnerUpdateHook

type RunnerUpdateHook interface {
	RunnerHook
	Update(*RunnerUpdateRequest) error
}

type RunnerUpdateRequest

type RunnerUpdateRequest struct {
	Alloc *structs.Allocation
}

type ShutdownHook

type ShutdownHook interface {
	RunnerHook

	Shutdown()
}

ShutdownHook may be implemented by AllocRunner or TaskRunner hooks and will be called when the agent process is being shutdown gracefully.

type TaskExitedHook

type TaskExitedHook interface {
	TaskHook

	// Exited is called when a task exits and may or may not be restarted.
	Exited(context.Context, *TaskExitedRequest, *TaskExitedResponse) error
}

type TaskExitedRequest

type TaskExitedRequest struct{}

type TaskExitedResponse

type TaskExitedResponse struct{}

type TaskHook

type TaskHook interface {
	Name() string
}

TaskHook is a lifecycle hook into the life cycle of a task runner.

type TaskPoststartHook

type TaskPoststartHook interface {
	TaskHook

	// Poststart is called after the task has started.
	Poststart(context.Context, *TaskPoststartRequest, *TaskPoststartResponse) error
}

type TaskPoststartRequest

type TaskPoststartRequest struct {
	// Exec hook (may be nil)
	DriverExec interfaces.ScriptExecutor

	// Network info (may be nil)
	DriverNetwork *drivers.DriverNetwork

	// TaskEnv is the task's environment
	TaskEnv *taskenv.TaskEnv

	// Stats collector
	DriverStats DriverStats
}

type TaskPoststartResponse

type TaskPoststartResponse struct{}

type TaskPreKillHook

type TaskPreKillHook interface {
	TaskHook

	// PreKilling is called right before a task is going to be killed or restarted.
	PreKilling(context.Context, *TaskPreKillRequest, *TaskPreKillResponse) error
}

type TaskPreKillRequest

type TaskPreKillRequest struct{}

type TaskPreKillResponse

type TaskPreKillResponse struct{}

type TaskPrestartHook

type TaskPrestartHook interface {
	TaskHook

	// Prestart is called before the task is started.
	Prestart(context.Context, *TaskPrestartRequest, *TaskPrestartResponse) error
}

type TaskPrestartRequest

type TaskPrestartRequest struct {
	// HookData is previously set data by the hook
	HookData map[string]string

	// Task is the task to run
	Task *structs.Task

	// TaskResources is the resources assigned to the task
	TaskResources *structs.AllocatedTaskResources

	// Vault token may optionally be set if a Vault token is available
	VaultToken string

	// TaskDir contains the task's directory tree on the host
	TaskDir *allocdir.TaskDir

	// TaskEnv is the task's environment
	TaskEnv *taskenv.TaskEnv
}

type TaskPrestartResponse

type TaskPrestartResponse struct {
	// Env is the environment variables to set for the task
	Env map[string]string

	// Mounts is the set of host volumes to mount into the task
	Mounts []*drivers.MountConfig

	// Devices are the set of devices to mount into the task
	Devices []*drivers.DeviceConfig

	// HookData allows the hook to emit data to be passed in the next time it is
	// run
	HookData map[string]string

	// Done lets the hook indicate that it should only be run once
	Done bool
}

type TaskStateHandler

type TaskStateHandler interface {
	// TaskStateUpdated is used to notify the alloc runner about task state
	// changes.
	TaskStateUpdated()
}

TaskStateHandler exposes a handler to be called when a task's state changes

type TaskStopHook

type TaskStopHook interface {
	TaskHook

	// Stop is called after the task has exited and will not be started again.
	Stop(context.Context, *TaskStopRequest, *TaskStopResponse) error
}

type TaskStopRequest

type TaskStopRequest struct{}

type TaskStopResponse

type TaskStopResponse struct{}

type TaskUpdateHook

type TaskUpdateHook interface {
	TaskHook
	Update(context.Context, *TaskUpdateRequest, *TaskUpdateResponse) error
}

type TaskUpdateRequest

type TaskUpdateRequest struct {
	VaultToken string

	// Alloc is the current version of the allocation (may have been
	// updated since the hook was created)
	Alloc *structs.Allocation

	// TaskEnv is the task's environment
	TaskEnv *taskenv.TaskEnv
}

type TaskUpdateResponse

type TaskUpdateResponse struct{}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL