fields

package
v0.0.0-...-8223eb1 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DynamicStrategy is used for dynamic node allocation to one of many
	// replaceable nodes, while StaticStrategy is used when a manifest
	// must be scheduled on specific nodes
	DynamicStrategy = Strategy("dynamic_strategy")
	StaticStrategy  = Strategy("static_strategy")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ID

type ID string

ID is a named type alias for Resource Controller IDs. This is preferred to the raw string format so that Go will typecheck its uses.

func ToRCID

func ToRCID(rcID string) (ID, error)

func (ID) String

func (id ID) String() string

String implements fmt.Stringer

type IDs

type IDs []ID

Implements sort.Interface to make a list of ids sortable lexicographically

func (IDs) Len

func (ids IDs) Len() int

func (IDs) Less

func (ids IDs) Less(i, j int) bool

func (IDs) Swap

func (ids IDs) Swap(i, j int)

type RC

type RC struct {
	// GUID for this controller
	ID ID

	// The pod manifest that should be scheduled on nodes
	Manifest manifest.Manifest

	// Defines the set of nodes on which the manifest can be scheduled
	NodeSelector labels.Selector

	// A set of labels that will be added to every pod scheduled by this controller.
	PodLabels labels.Set

	// The desired number of instances of the manifest that should be
	// scheduled.
	ReplicasDesired int

	// When disabled, this controller will not make any scheduling changes
	Disabled bool

	// Distinguishes between dynamic, static or other strategies for allocating
	// nodes on which the rc can schedule the manifest.
	AllocationStrategy Strategy
}

RC holds the runtime state of a Resource Controller as saved in Consul.

func (RC) MarshalJSON

func (rc RC) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for serializing the RC to JSON format.

The RC struct contains interfaces (manifest.Manifest, labels.Selector), and unmarshaling into a nil, non-empty interface is impossible (unless the value is a JSON null), because the unmarshaler doesn't know what structure to allocate there we own manifest.Manifest, but we don't own labels.Selector, so we have to implement the json marshaling here to wrap around the interface values

func (RC) ToRaw

func (rc RC) ToRaw() (RawRC, error)

Converts an RC to a type that will marshal cleanly as JSON

func (*RC) UnmarshalJSON

func (rc *RC) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for deserializing the JSON representation of an RC.

type RawRC

type RawRC struct {
	ID           ID         `json:"id"`
	Manifest     string     `json:"manifest"`
	NodeSelector string     `json:"node_selector"`
	PodLabels    labels.Set `json:"pod_labels"`

	// ReplicasDesired is an int pointer so we can distinguish between a
	// zero-count indicating the RC handler should remove any and all pods
	// from a case (for instance if the json key was changed) where golang
	// is defaulting to the 0 value
	ReplicasDesired    *int     `json:"replicas_desired"`
	Disabled           bool     `json:"disabled"`
	AllocationStrategy Strategy `json:"allocation_strategy"`
}

RawRC defines the JSON format used to store data into Consul. It should only be used while (de-)serializing the RC state. Prefer using the "RC" when possible.

type Strategy

type Strategy string

Strategy is a type alias used for node allocation strategies.

func (Strategy) String

func (s Strategy) String() string

Jump to

Keyboard shortcuts

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