Documentation
¶
Index ¶
- Constants
- type Agent
- type AgentSet
- type State
- func (s *State) NotifyUpscale(newResources *api.RawResources) (*struct{}, int, error)
- func (s *State) RegisterAgent(info *api.AgentDesc) (*api.InformantDesc, int, error)
- func (s *State) TryDownscale(target *api.RawResources) (*api.DownscaleResult, int, error)
- func (s *State) UnregisterAgent(info *api.AgentDesc) (*api.UnregisterAgent, int, error)
Constants ¶
const ( PrometheusPort uint16 = 9100 CheckDeadlockDelay time.Duration = 1 * time.Second CheckDeadlockTimeout time.Duration = 250 * time.Millisecond AgentBackgroundCheckDelay time.Duration = 10 * time.Second AgentBackgroundCheckTimeout time.Duration = 250 * time.Millisecond AgentResumeTimeout time.Duration = 100 * time.Millisecond AgentSuspendTimeout time.Duration = 200 * time.Millisecond )
const ProtocolVersion uint32 = 1
ProtocolVersion is the current version of the agent<->informant protocol in use by this informant
Currently, each VM informant supports only one version at a time. In the future, this may change.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Agent ¶
type Agent struct {
// contains filtered or unexported fields
}
func (*Agent) CheckID ¶
CheckID checks that the Agent's ID matches what's expected
If the agent has already been registered, then a failure in this method will unregister the agent.
If the Agent is unregistered before the call to CheckID() completes, the request will be cancelled and this method will return context.Canceled.
func (*Agent) EnsureUnregistered ¶
EnsureUnregistered unregisters the Agent if it is currently registered, signalling the AgentSet to use a new Agent if it isn't already
Returns whether the agent was the current Agent in use.
func (*Agent) Resume ¶
Resume attempts to restore the Agent as the current one in use, sending a request to its /resume endpoint
If the Agent is unregistered before the call to Resume() completes, the request will be cancelled and this method will return context.Canceled.
If the request fails, the Agent will be unregistered.
func (*Agent) SpawnSuspend ¶
SpawnSuspend signals to the Agent that it is not *currently* in use, sending a request to its /suspend endpoint
Unlike other similar methods on Agent, SpawnSuspend will only wait for the request to be picked up by the request executor. Handling the result of the request is done in a separate goroutine.
If the Agent is unregistered before the call to Suspend() completes, the request will be cancelled and this method will return context.Canceled.
If the request fails, the Agent will be unregistered.
type AgentSet ¶
type AgentSet struct {
// contains filtered or unexported fields
}
AgentSet is the global state handling various autoscaler-agents that we could connect to
func NewAgentSet ¶
func NewAgentSet() *AgentSet
NewAgentSet creates a new AgentSet and starts the necessary background tasks
On completion, the background tasks should be ended with the Stop method.
type State ¶
type State struct {
// contains filtered or unexported fields
}
State is the global state of the informant
func (*State) NotifyUpscale ¶
func (s *State) NotifyUpscale(newResources *api.RawResources) (*struct{}, int, error)
NotifyUpscale signals that the VM's resource usage has been increased to the new amount
Returns: body (if successful), status code and error (if unsuccessful)
func (*State) RegisterAgent ¶
RegisterAgent registers a new or updated autoscaler-agent
Returns: body (if successful), status code, error (if unsuccessful)
func (*State) TryDownscale ¶
func (s *State) TryDownscale(target *api.RawResources) (*api.DownscaleResult, int, error)
TryDownscale tries to downscale the VM's current resource usage, returning whether the proposed amount is ok
Returns: body (if successful), status code and error (if unsuccessful)
func (*State) UnregisterAgent ¶
UnregisterAgent unregisters the autoscaler-agent given by info, if it is currently registered
If a different autoscaler-agent is currently registered, this method will do nothing.
Returns: body (if successful), status code and error (if unsuccessful)