client

package
v0.0.0-...-56e5da9 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2018 License: MPL-2.0 Imports: 28 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
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

func (r *Allocator) DestroyState() error

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

func (r *Allocator) SaveState() error

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

func (*Allocator) WaitCh

func (r *Allocator) WaitCh() <-chan struct{}

WaitCh returns a channel to wait for termination

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 NewClient

func NewClient(cfg *config.ClientConfig, logger *ulog.Logger) (*Client, error)

NewClient is used to create a new client from the given configuration

func (*Client) Datacenter

func (c *Client) Datacenter() string

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

func (c *Client) GetServers() []string

GetServers returns the list of server servers this client is aware of.

func (*Client) Leave

func (c *Client) Leave() error

Leave is used to prepare the client to leave the cluster

func (*Client) Node

func (c *Client) Node() *models.Node

Node returns the locally registered node

func (*Client) RPC

func (c *Client) RPC(method string, args interface{}, reply interface{}) error

RPC is used to forward an RPC call to a server server, or fail if no servers.

func (*Client) Region

func (c *Client) Region() string

Region returns the region for the given client

func (*Client) SetServers

func (c *Client) SetServers(servers []string) error

SetServers sets a new list of server servers to connect to. As long as one server is resolvable no error is returned.

func (*Client) Shutdown

func (c *Client) Shutdown() error

Shutdown is used to tear down the client

func (*Client) Stats

func (c *Client) Stats() map[string]map[string]string

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

type TaskStateUpdater func(taskName, state string, event *models.TaskEvent)

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

func (r *Worker) Destroy(event *models.TaskEvent)

Destroy is used to indicate that the task context should be destroyed. The event parameter provides a context for the destroy.

func (*Worker) DestroyState

func (r *Worker) DestroyState() error

DestroyState is used to cleanup after ourselves

func (*Worker) Kill

func (r *Worker) Kill(source, reason string, fail bool)

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) Restart

func (r *Worker) Restart(source, reason string)

Restart will restart the task

func (*Worker) Run

func (r *Worker) Run()

Run is a long running routine used to manage the task

func (*Worker) SaveState

func (r *Worker) SaveState() error

SaveState is used to snapshot our store

func (*Worker) UnblockStart

func (r *Worker) UnblockStart(source string)

UnblockStart unblocks the starting of the task. It currently assumes only consul-template will unblock

func (*Worker) WaitCh

func (r *Worker) WaitCh() <-chan struct{}

WaitCh returns a channel to wait for termination

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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