Documentation ¶
Overview ¶
Package plan contains the logic for creating a plan to reassign floating IPs to servers to keep things balanced and healthy.
Index ¶
- type Plan
- type ReassignFloatingIPAction
- type State
- func (s State) CandidateFloatingIPs() []resource.FloatingIP
- func (s State) CandidateServers() []*resource.WithStatus[resource.Server]
- func (s State) FloatingIPsAsSlice() resource.FloatingIPs
- func (s State) FloatingIPsByServer() map[string]resource.FloatingIPs
- func (s State) FloatingIPsTargetedOutsideGroup() resource.FloatingIPs
- func (s State) HasServersWithUnknownStatus() bool
- func (s State) NumUnhealthyServers() int
- func (s State) ServersAsSlice() resource.WithStatusSlice[resource.Server]
- func (s State) UnassignedFloatingIPs() []resource.FloatingIP
- func (s State) UnhealthyFloatingIPs() []resource.FloatingIP
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Plan ¶
type Plan struct { // ID is a random UUID to identify the plan. ID uuid.UUID Actions []ReassignFloatingIPAction }
Plan describes the changeset to be applied to the cloud resources.
func New ¶
New takes the current state of the cloud resources and returns a plan for reassigning floating IPs.
func (*Plan) AddAction ¶
func (p *Plan) AddAction(action ReassignFloatingIPAction)
AddAction adds an action to the plan.
func (Plan) ToBeReassignedMap ¶
ToBeReassignedMap returns the floating IP IDs that will be reassigned.
type ReassignFloatingIPAction ¶
type ReassignFloatingIPAction struct { // FloatingIPID is the ID of the floating IP to be reassigned. FloatingIPID string // ServerID string is the ID of the server to which the floating IP should be reassigned. ServerID string }
ReassignFloatingIPAction is a plan to reassign a floating IP to a different server.
func (ReassignFloatingIPAction) String ¶
func (a ReassignFloatingIPAction) String() string
String returns a string representation of the action.
type State ¶
type State struct { FloatingIPs map[string]resource.FloatingIP Servers map[string]*resource.WithStatus[resource.Server] }
State represents the current state of the cloud resources.
func NewState ¶
func NewState(floatingIPs []resource.FloatingIP, servers []*resource.WithStatus[resource.Server]) State
NewState creates a new state.
func NewStateFromGroup ¶
NewStateFromGroup creates a new state from a group of resources. The resources will start with an unknown status.
func (State) CandidateFloatingIPs ¶
func (s State) CandidateFloatingIPs() []resource.FloatingIP
CandidateFloatingIPs returns all floating IPs that we should me managing the targets of.
func (State) CandidateServers ¶
func (s State) CandidateServers() []*resource.WithStatus[resource.Server]
CandidateServers returns all healthy servers, or all servers if there are no healthy ones. It returns them in a fixed order.
func (State) FloatingIPsAsSlice ¶ added in v0.2.0
func (s State) FloatingIPsAsSlice() resource.FloatingIPs
FloatingIPsAsSlice returns the floating IPs as a slice in a fixed order.
func (State) FloatingIPsByServer ¶
func (s State) FloatingIPsByServer() map[string]resource.FloatingIPs
FloatingIPsByServer returns a map of server IDs to floating IPs.
func (State) FloatingIPsTargetedOutsideGroup ¶
func (s State) FloatingIPsTargetedOutsideGroup() resource.FloatingIPs
FloatingIPsTargetedOutsideGroup returns the floating IPs that are targeted at unknown servers.
func (State) HasServersWithUnknownStatus ¶
HasServersWithUnknownStatus returns true if there are servers with an unknown status.
func (State) NumUnhealthyServers ¶
NumUnhealthyServers returns the number of unhealthy servers.
func (State) ServersAsSlice ¶ added in v0.2.0
func (s State) ServersAsSlice() resource.WithStatusSlice[resource.Server]
ServersAsSlice returns the servers as a slice in a fixed order.
func (State) UnassignedFloatingIPs ¶
func (s State) UnassignedFloatingIPs() []resource.FloatingIP
UnassignedFloatingIPs returns all floating IPs that are not assigned to a server.
func (State) UnhealthyFloatingIPs ¶
func (s State) UnhealthyFloatingIPs() []resource.FloatingIP
UnhealthyFloatingIPs returns all floating IPs that are assigned to an unhealthy server.