Documentation
¶
Index ¶
- Constants
- type AllocStateUpdater
- type AllocStatsReporter
- type Allocator
- func (r *Allocator) Alloc() *models.Allocation
- func (r *Allocator) Destroy()
- func (r *Allocator) DestroyState() error
- func (r *Allocator) LatestAllocStats(taskFilter string) (*models.AllocStatistics, error)
- func (r *Allocator) Run()
- func (r *Allocator) SaveState() error
- func (r *Allocator) StatsReporter() AllocStatsReporter
- func (r *Allocator) Update(update *models.Allocation)
- func (r *Allocator) WaitCh() <-chan struct{}
- type Client
- func (c *Client) Datacenter() string
- func (c *Client) GetAllocStats(allocID string) (AllocStatsReporter, error)
- func (c *Client) GetClientAlloc(allocID string) (*models.Allocation, error)
- func (c *Client) GetServers() []string
- func (c *Client) Leave() error
- func (c *Client) Node() *models.Node
- func (c *Client) RPC(method string, args interface{}, reply interface{}) error
- func (c *Client) Region() string
- func (c *Client) SetServers(servers []string) error
- func (c *Client) Shutdown() error
- func (c *Client) Stats() map[string]map[string]string
- func (c *Client) StatsReporter() ClientStatsReporter
- type ClientStatsReporter
- type RestartTracker
- func (r *RestartTracker) GetReason() string
- func (r *RestartTracker) GetState() (string, time.Duration)
- func (r *RestartTracker) SetRestartTriggered() *RestartTracker
- func (r *RestartTracker) SetStartError(err error) *RestartTracker
- func (r *RestartTracker) SetWaitResult(res *models.WaitResult) *RestartTracker
- type TaskStateUpdater
- type Worker
- func (r *Worker) Destroy(event *models.TaskEvent)
- func (r *Worker) DestroyState() error
- func (r *Worker) Kill(source, reason string, fail bool)
- func (r *Worker) LatestTaskStats() *models.TaskStatistics
- func (r *Worker) MarkReceived()
- func (r *Worker) Restart(source, reason string)
- func (r *Worker) Run()
- func (r *Worker) SaveState() error
- func (r *Worker) UnblockStart(source string)
- func (r *Worker) WaitCh() <-chan struct{}
Constants ¶
const ( ReasonUnrecoverableErrror = "Error was unrecoverable" ReasonWithinPolicy = "Restart within policy" ReasonDelay = "Exceeded allowed attempts, applying a delay" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AllocStateUpdater ¶
type AllocStateUpdater func(alloc *models.Allocation)
AllocStateUpdater is used to update the status of an allocation
type AllocStatsReporter ¶
type AllocStatsReporter interface {
LatestAllocStats(taskFilter string) (*models.AllocStatistics, error)
}
type Allocator ¶
type Allocator struct {
// contains filtered or unexported fields
}
Allocator is used to wrap an allocation and provide the execution context.
func NewAllocator ¶
func NewAllocator(logger *log.Logger, config *config.ClientConfig, updater AllocStateUpdater, alloc *models.Allocation, workUpdates chan *models.TaskUpdate) *Allocator
NewAllocator is used to create a new allocation context
func (*Allocator) Alloc ¶
func (r *Allocator) Alloc() *models.Allocation
Alloc returns the associated allocation
func (*Allocator) Destroy ¶
func (r *Allocator) Destroy()
Destroy is used to indicate that the allocation context should be destroyed
func (*Allocator) DestroyState ¶
DestroyState is used to cleanup after ourselves
func (*Allocator) LatestAllocStats ¶
func (r *Allocator) LatestAllocStats(taskFilter string) (*models.AllocStatistics, error)
LatestAllocStats returns the latest allocation stats. If the optional taskFilter is set the allocation stats will only include the given task.
func (*Allocator) Run ¶
func (r *Allocator) Run()
Run is a long running goroutine used to manage an allocation
func (*Allocator) SaveState ¶
SaveState is used to snapshot the store of the alloc runner if the fullSync is marked as false only the store of the Alloc Runner is snapshotted. If fullSync is marked as true, we snapshot all the Task Runners associated with the Alloc
func (*Allocator) StatsReporter ¶
func (r *Allocator) StatsReporter() AllocStatsReporter
StatsReporter returns an interface to query resource usage statistics of an allocation
func (*Allocator) Update ¶
func (r *Allocator) Update(update *models.Allocation)
Update is used to update the allocation of the context
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is used to implement the client interaction with Udup. Clients are expected to register as a schedulable node to the servers, and to run allocations as determined by the servers.
func (*Client) Datacenter ¶
Datacenter returns the datacenter for the given client
func (*Client) GetAllocStats ¶
func (c *Client) GetAllocStats(allocID string) (AllocStatsReporter, error)
func (*Client) GetClientAlloc ¶
func (c *Client) GetClientAlloc(allocID string) (*models.Allocation, error)
GetClientAlloc returns the allocation from the client
func (*Client) GetServers ¶
GetServers returns the list of server servers this client is aware of.
func (*Client) SetServers ¶
SetServers sets a new list of server servers to connect to. As long as one server is resolvable no error is returned.
func (*Client) Stats ¶
Stats is used to return statistics for debugging and insight for various sub-systems
func (*Client) StatsReporter ¶
func (c *Client) StatsReporter() ClientStatsReporter
StatsReporter exposes the various APIs related resource usage of a Udup client
type ClientStatsReporter ¶
type ClientStatsReporter interface {
// GetAllocStats returns the AllocStatsReporter for the passed allocation.
// If it does not exist an error is reported.
GetAllocStats(allocID string) (AllocStatsReporter, error)
}
ClientStatsReporter exposes all the APIs related to resource usage of a Udup Client
type RestartTracker ¶
type RestartTracker struct {
// contains filtered or unexported fields
}
func (*RestartTracker) GetReason ¶
func (r *RestartTracker) GetReason() string
GetReason returns a human-readable description for the last store returned by GetState.
func (*RestartTracker) GetState ¶
func (r *RestartTracker) GetState() (string, time.Duration)
GetState returns the tasks next store given the set exit code and start error. One of the following states are returned:
- TaskRestarting - Task should be restarted
- TaskNotRestarting - Task should not be restarted and has exceeded its restart policy.
- TaskTerminated - Task has terminated successfully and does not need a restart.
If TaskRestarting is returned, the duration is how long to wait until starting the task again.
func (*RestartTracker) SetRestartTriggered ¶
func (r *RestartTracker) SetRestartTriggered() *RestartTracker
SetRestartTriggered is used to mark that the task has been signalled to be restarted
func (*RestartTracker) SetStartError ¶
func (r *RestartTracker) SetStartError(err error) *RestartTracker
SetStartError is used to mark the most recent start error. If starting was successful the error should be nil.
func (*RestartTracker) SetWaitResult ¶
func (r *RestartTracker) SetWaitResult(res *models.WaitResult) *RestartTracker
SetWaitResult is used to mark the most recent wait result.
type TaskStateUpdater ¶
TaskStateUpdater is used to signal that tasks store has changed.
type Worker ¶
type Worker struct {
// contains filtered or unexported fields
}
Worker is used to wrap a task within an allocation and provide the execution context.
func NewWorker ¶
func NewWorker(logger *log.Logger, config *config.ClientConfig, updater TaskStateUpdater, alloc *models.Allocation, task *models.Task, workUpdates chan *models.TaskUpdate) *Worker
NewWorker is used to create a new task context
func (*Worker) Destroy ¶
Destroy is used to indicate that the task context should be destroyed. The event parameter provides a context for the destroy.
func (*Worker) DestroyState ¶
DestroyState is used to cleanup after ourselves
func (*Worker) Kill ¶
Kill will kill a task and store the error, no longer restarting the task. If fail is set, the task is marked as having failed.
func (*Worker) LatestTaskStats ¶
func (r *Worker) LatestTaskStats() *models.TaskStatistics
LatestResourceUsage returns the last resource utilization datapoint collected
func (*Worker) MarkReceived ¶
func (r *Worker) MarkReceived()
MarkReceived marks the task as received.
func (*Worker) UnblockStart ¶
UnblockStart unblocks the starting of the task. It currently assumes only consul-template will unblock