messages

package
v0.0.0-...-3e52749 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CapacityCores   = "_cores"
	CapacityMemory  = "_memoryInMB"
	CapacityDisk    = "_diskInGB"
	CapacityNetwork = "_networkBandwidthInMbps"
)
View Source
const (
	// TagInvalid is a reserved, unused message type
	TagInvalid int = iota

	// TagGetStatus identifies a status request message
	TagGetStatus

	// TagSetConnection identifies a network connection change message
	TagSetConnection

	// TagSetPower identifies a power change message
	TagSetPower

	// TagTimerExpiry identifies a timer expiration message.
	TagTimerExpiry

	// TagSetWorkload identifies a set workload information message.
	TagSetWorkload

	// TagRemoveWorkload identifies a remove workload message.
	TagRemoveWorkload
)

Define the unique values used to identify the message type during processing.

View Source
const (
	// AcceleratorPrefix is put in front of any accelerator name to ensure that
	// there is no collision with the core Capacity categories listed above.
	AcceleratorPrefix = "a_"
)

Variables

This section is empty.

Functions

func DropMessage

func DropMessage(ctx context.Context, machine *sm.SM, msg sm.Envelope) bool

DropMessage is an action state processor that closes the channel without issuing any message. This indicates that the state machine did not process the request, including finding an error to send back. The closure avoids real time delays in waiting for a response, and instead to move any such delay into simulated time.

func InvalidTargetResponse

func InvalidTargetResponse(occursAt int64) *sm.Response

InvalidTargetResponse constructs a failure response message with an invalid target error code.

func NewStatusResponse

func NewStatusResponse(occursAt int64, body proto.Message) *sm.Response

NewStatusResponse provides a newly created status message.

Types

type Capacity

type Capacity struct {
	// Consumables are named units of capacity that are used by a workload such
	// that the amount available to other workloads is reduced by that amount.
	// For example, a core may only be used by one workload at a time.
	Consumables map[string]float64

	// Features are statements of capabilities that are available for use, but
	// that are not consumed when used.  For example, the presence of security
	// enclave support would be a feature.
	Features map[string]bool
}

Capacity defines the consumable and capability portions of a blade or workload.

func CapacityProtoToMessage

func CapacityProtoToMessage(x *pb.BladeCapacity) *Capacity

CapacityProtoToMessage returns a Capacity instance with the field values as set in the supplied BladeCapacity protobuf structure.

func NewCapacity

func NewCapacity() *Capacity

NewCapacity creates a new, blank, Capacity instance.

func (*Capacity) Clone

func (s *Capacity) Clone() *Capacity

Clone produces a copy of this Capacity instance.

func (*Capacity) Consume

func (s *Capacity) Consume(v *pb.BladeCapacity)

Consume subtracts the various capacity attributes passed by the caller from this instance.

func (*Capacity) Release

func (s *Capacity) Release(v *pb.BladeCapacity)

Release returns the supplied capacity attributes to this instance.

func (*Capacity) ToProto

func (s *Capacity) ToProto() *pb.BladeCapacity

ToProto returns the current instance values in the protobuf structure form.

Note that accelerator values are not currently included.

func (*Capacity) WouldExceed

func (s *Capacity) WouldExceed(v *pb.BladeCapacity) bool

WouldExceed determines if the consumption of the capacity specified by the caller would exceed any of the capacity attributes of this instance. If any would, this function returns true.

type GetStatus

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

GetStatus defines a request for the current execution status of the target inventory element.

func NewGetStatus

func NewGetStatus(
	ctx context.Context,
	target *MessageTarget,
	guard int64,
	ch chan *sm.Response) *GetStatus

NewGetStatus provides a newly created get status request for the target.

func (*GetStatus) SendVia

func (m *GetStatus) SendVia(ctx context.Context, r viaSender) error

SendVia reflects that the get status request is a message from within the simulation, so either goes to the PDU directly (as a simplification of the simulated inventory structure), or always passes through the TOR.

func (*GetStatus) String

func (m *GetStatus) String() string

type MessageTarget

type MessageTarget struct {
	Rack string
	// contains filtered or unexported fields
}

MessageTarget describes the target element for the enclosing message.

func HardwareToTarget

func HardwareToTarget(hw *inventory.Hardware) *MessageTarget

HardwareToTarget is a temporary function that converts a storage hardware element's address into a rack-local message target. See note about the target type above for why this is temporary.

func NewTargetBlade

func NewTargetBlade(name string, id int64, port int64) *MessageTarget

NewTargetBlade creates a new target instance that specifies the designated itemId in the specified rack.

func NewTargetPdu

func NewTargetPdu(name string, id int64, port int64) *MessageTarget

NewTargetPdu creates a new target instance that specifies the designated rack's PDU.

func NewTargetTor

func NewTargetTor(name string, id int64, port int64) *MessageTarget

NewTargetTor creates a new target instance that specifies the designated rack's TOR.

func (*MessageTarget) AsHardware

func (m *MessageTarget) AsHardware() *inventory.Hardware

AsHardware returns the Hardware instance that corresponds to this message target.

func (*MessageTarget) Describe

func (m *MessageTarget) Describe() string

Describe produces a string that describes the target element's logical address.

func (*MessageTarget) ElementId

func (m *MessageTarget) ElementId() int64

func (*MessageTarget) Equals

func (m *MessageTarget) Equals(x *MessageTarget) bool

Equals determines if the supplied target specifies the same element as this instance. It returns true if it does.

func (*MessageTarget) IsBlade

func (m *MessageTarget) IsBlade() bool

func (*MessageTarget) IsPdu

func (m *MessageTarget) IsPdu() bool

func (*MessageTarget) IsTor

func (m *MessageTarget) IsTor() bool

func (*MessageTarget) Key

func (m *MessageTarget) Key() string

Key produces a structured string that can be used simply as a rack-local id for an element in the rack.

func (*MessageTarget) Port

func (m *MessageTarget) Port() int64

func (*MessageTarget) String

func (m *MessageTarget) String() string

type RepairActionState

type RepairActionState interface {
	sm.State

	// Power is the function that responds to a setPower message.
	Power(ctx context.Context, sm *sm.SM, msg *SetPower)

	// Connect is the function that responds to a setConnection message.
	Connect(ctx context.Context, sm *sm.SM, msg *SetConnection)

	// Timeout is the function that processes a timer expiration message.
	Timeout(ctx context.Context, sm *sm.SM, msg *TimerExpiry)
}

RepairActionState is the abstract definition that all inventory state machines must implement.

type RepairMessage

type RepairMessage interface {
	// contains filtered or unexported methods
}

RepairMessage defines the required function signatures for all inventory repair messages.

type SetConnection

type SetConnection struct {

	// Enabled designates whether the simulated network connection is to be
	// Enabled or disabled.
	Enabled bool
	// contains filtered or unexported fields
}

SetConnection is the repair message that directs a change in the simulated network connection setting.

func NewSetConnection

func NewSetConnection(
	ctx context.Context,
	target *MessageTarget,
	guard int64,
	enabled bool,
	ch chan *sm.Response) *SetConnection

NewSetConnection creates a new setConnection message with the values provided.

func (*SetConnection) SendVia

func (m *SetConnection) SendVia(ctx context.Context, r viaSender) error

SendVia forwards the repair message to the rack's TOR for processing. This is not the final destination for the message.

func (*SetConnection) String

func (m *SetConnection) String() string

String provides a formatted description of the message.

type SetPower

type SetPower struct {

	// On designates whether the simulated power is to be On or off.
	On bool
	// contains filtered or unexported fields
}

SetPower is the repair message that directs a change in the simulated power setting.

func NewSetPower

func NewSetPower(
	ctx context.Context,
	target *MessageTarget,
	guard int64,
	on bool,
	ch chan *sm.Response) *SetPower

NewSetPower creates a new SetPower message with the values provided.

func (*SetPower) SendVia

func (m *SetPower) SendVia(ctx context.Context, r viaSender) error

SendVia forwards the repair message to the rack's PDU for processing. This may or may not be the final destination for the message.

func (*SetPower) String

func (m *SetPower) String() string

String provides a formatted description of the message.

type SetWorkload

type SetWorkload struct {
	Name     string
	State    pb.UsageInstanceState
	Revision int64

	Consumes *pb.BladeCapacity
	// contains filtered or unexported fields
}

SetWorkload is a struct that specifies an individual workload instance, its running state, and associate resource requirements.

func NewSetWorkload

func NewSetWorkload(
	ctx context.Context,
	target *MessageTarget,
	guard int64,
	name string,
	state pb.UsageInstanceState,
	revision int64,
	consumes *pb.BladeCapacity,
	ch chan *sm.Response) *SetWorkload

NewSetWorkload creates a SetWorkload message with the supplied properties.

func (*SetWorkload) SendVia

func (m *SetWorkload) SendVia(ctx context.Context, r viaSender) error

SendVia forwards the message instance to the target blade via the simulated TOR wired to the target, as the message is a simulated control path message.

func (*SetWorkload) String

func (m *SetWorkload) String() string

String returns a formatted string for the instance.

type StatusMessage

type StatusMessage interface {
	GetStatus(ctx context.Context, sm *sm.SM, s RepairActionState)
	// contains filtered or unexported methods
}

StatusMessage defines the required function signatures for all inventory simulation status request messages.

type TimerExpiry

type TimerExpiry struct {

	// Id is the value used to identify which outstanding timer has expired.
	Id int64

	// timer expiration context - what the state machine needs, if anything, to
	// work On the expiration notice.
	Body sm.Envelope
	// contains filtered or unexported fields
}

TimerExpiry is the message used to notify a simulated inventory element that a specific timer, designated by the Id field, has expired.

func NewTimerExpiry

func NewTimerExpiry(
	target *MessageTarget,
	guard int64,
	id int64,
	body sm.Envelope,
	ch chan *sm.Response) *TimerExpiry

NewTimerExpiry creates a new TimerExpiry message.

func (*TimerExpiry) SendVia

func (m *TimerExpiry) SendVia(ctx context.Context, r viaSender) error

SendVia forwards the timer expiration directly to the target element. This either sends the enclosed body, or the outer TimerExpiry message itself, if no message body is present.

func (*TimerExpiry) String

func (m *TimerExpiry) String() string

String provides a formatted description of the message.

Jump to

Keyboard shortcuts

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