scale

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: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Direction

type Direction string
const (
	DirectionIn   Direction = "in"
	DirectionOut  Direction = "out"
	DirectionNone Direction = "none"
)

func (*Direction) String

func (d *Direction) String() string

type GroupReq

type GroupReq struct {

	// Direction is the scaling direction which the group is requested to change.
	Direction Direction

	// Count is the number by which to change the count by in the desired direction. This
	// information can also be found within the GroupScalingPolicy, but the API and the internal
	// autoscaler have different ways in which to process data so it is their responsibility to
	// populate this field for use and moves this logic away from the trigger.
	Count int

	// GroupName is the name of the job group to scale in this request.
	GroupName string

	// GroupScalingPolicy should include the job group scaling policy if it exists within the
	// Sherpa server.
	GroupScalingPolicy *policy.GroupScalingPolicy

	// Time is the UnixNano time representation which indicates when this scaling request was first
	// triggered. This is to help coordinate with checks such as cooldown and ensure a single time
	// can be used.
	Time int64

	// Meta is the meta data which is optionally submitted when requesting a scaling activity for a
	// job group. This is free-form and can contain any information the user deems relevant.
	Meta map[string]string
}

GroupReq is a single item of scaling information for a single job group.

func (*GroupReq) MarshalZerologObject

func (g *GroupReq) MarshalZerologObject(e *zerolog.Event)

type Scale

type Scale interface {
	// Trigger performs scaling of 1 or more job groups which belong to the same job.
	Trigger(string, []*GroupReq, state.Source) (*ScalingResponse, int, error)

	// GetDeploymentChannel is used to return the channel where updates to Nomad deployments should
	// be sent.
	GetDeploymentChannel() chan interface{}

	// RunDeploymentUpdateHandler is used to trigger the long running process which handles
	// messages sent to the deployment update channel.
	RunDeploymentUpdateHandler()

	// JobGroupIsDeploying checks internal references to identify if the queried job group is
	// currently in deployment.
	JobGroupIsDeploying(job, group string) bool

	// JobGroupIsInCooldown checks whether the job group in question is currently in scaling
	// cooldown using the input time as the comparison.
	JobGroupIsInCooldown(job, group string, cooldown int, time int64) (bool, error)
	// contains filtered or unexported methods
}

Scale is the interface used for scaling a Nomad job.

func NewScaler

func NewScaler(c *api.Client, l zerolog.Logger, state scale.Backend, strictChecking bool) Scale

type Scaler

type Scaler struct {
	// contains filtered or unexported fields
}

func (*Scaler) GetDeploymentChannel added in v0.2.0

func (s *Scaler) GetDeploymentChannel() chan interface{}

GetDeploymentChannel will return the channel where deployment updates should be sent.

func (*Scaler) JobGroupIsDeploying added in v0.2.0

func (s *Scaler) JobGroupIsDeploying(job, group string) bool

JobGroupIsDeploying returns a boolean to indicate where or not the specified job and group is currently in deployment.

func (*Scaler) JobGroupIsInCooldown added in v0.3.0

func (s *Scaler) JobGroupIsInCooldown(job, group string, cooldown int, time int64) (bool, error)

JobGroupIsInCooldown satisfies the JobGroupIsInCooldown func within the Scale interface.

func (*Scaler) RunDeploymentUpdateHandler added in v0.2.0

func (s *Scaler) RunDeploymentUpdateHandler()

RunDeploymentUpdateHandler is used to handle updates and shutdowns when monitoring Nomad job deployments.

func (*Scaler) Trigger

func (s *Scaler) Trigger(jobID string, groupReqs []*GroupReq, source state.Source) (*ScalingResponse, int, error)

Trigger performs scaling of 1 or more job groups which belong to the same job.

The return values indicate:

  • the Nomad API job register response
  • the HTTP return code, used for the Sherpa API
  • any error

type ScalingResponse added in v0.1.0

type ScalingResponse struct {
	ID           uuid.UUID
	EvaluationID string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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