state

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2020 License: MPL-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// StatusCompleted means the changes to the Nomad job specification due to a scaling
	// requirement were registered to the Nomad API without error.
	StatusCompleted = "Completed"

	// StatusFailed means there was an error calling the Nomad API when attempting to register
	// the job which contained altered groups as a result of a scaling event.
	StatusFailed = "Failed"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ClusterInfo added in v0.2.0

type ClusterInfo struct {

	// ID is the uuid assigned to this cluster.
	ID uuid.UUID

	// Name is the human friendly name of the cluster. It is designed to be used for human
	// identification of clusters as it is much easier than a UUID.
	Name string
}

ClusterInfo is our high level cluster information which holds unique identifiers for each cluster.

type ClusterMember added in v0.2.0

type ClusterMember struct {

	// ID is the unique identifier of the Sherpa server instance.
	ID uuid.UUID

	// Addr is the Sherpa server address where the API is listening and present. This address
	// should include the protocol, host, and port.
	Addr string

	// AdvertiseAddr is the Sherpa server advertise address which can be used for NAT traversal
	// when redirecting requests to the cluster leader.
	AdvertiseAddr string
}

ClusterMember represents an individual members of a cluster and a member is considered eligible to perform leader actions.

type EventDetails

type EventDetails struct {
	// Count is the number by which the group was changed.
	Count int

	// Direction is direction in which the scaling took place. This can be either in or out
	// representing subtraction and addition respectively.
	Direction string
}

EventDetails contains information to describe what changes took place during the scaling action.

type ScalingEvent

type ScalingEvent struct {
	// ID is the scaling ID.
	ID uuid.UUID

	// EvalID is the Nomad evaluation ID which was created as a result of submitting the updated
	// job to the Nomad API.
	EvalID string

	// Source shows the origin source of the scaling event.
	Source Source

	// Time is a UnixNano timestamp declaring when the scaling event trigger took place.
	Time int64

	// Status is the end status of the scaling event.
	Status Status

	// Details contains information about exactly what action was taken on the job group during the
	// scaling event.
	Details EventDetails

	Meta map[string]string
}

ScalingEvent represents a single scaling event state entry that is persisted to the backend store.

type ScalingEventMessage

type ScalingEventMessage struct {
	ID        uuid.UUID
	GroupName string
	EvalID    string
	Source    Source
	Time      int64
	Status    Status
	Count     int
	Direction string
	Meta      map[string]string
}

ScalingEventMessage is the message sent to the state writer containing all the required information to construct the persistent state entry.

type ScalingState

type ScalingState struct {
	// Events stores all scaling events to have been invoked through the Sherpa server. These
	// events can be from any source. Each scaling event will be registered with a UUID; each event
	// can encompass a single job, and any number of groups within that job.
	Events map[uuid.UUID]map[string]*ScalingEvent

	// LatestEvents holds the most recent scaling event to occur for each job group. The map key
	// takes the form of job-name:group-name. When a new scaling action takes place for a
	// particular job group, the entry here should be overwritten. This provides and fast way to
	// lookup last events and is currently ignored from GC.
	LatestEvents map[string]*ScalingEvent
}

ScalingState is the internal Sherpa scaling state used to track scaling events invoked.

type Source

type Source string

Source represents how the scaling action was invoked.

const (
	// SourceAPI is a scaling event invocation via the HTTP API.
	SourceAPI Source = "API"

	// SourceInternalAutoscaler is a scaling event invoked by the internal autoscaler.
	SourceInternalAutoscaler Source = "InternalAutoscaler"
)

func (Source) String

func (s Source) String() string

type Status

type Status string

Status represents whether the scaling event was classed as successful or not. Currently this is dependant on if the job managed to be submitted to the Nomad API as Sherpa does not perform any checking after.

func (Status) String

func (s Status) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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