Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RetryContext ¶
RetryContext is a basic wrapper around StateChangeConf that will just retry a function until it no longer returns an error.
Cancellation from the passed in context will propagate through to the underlying StateChangeConf
Types ¶
type NotFoundError ¶
type NotFoundError struct { LastError error LastRequest interface{} LastResponse interface{} Message string Retries int }
func (*NotFoundError) Error ¶
func (e *NotFoundError) Error() string
func (*NotFoundError) Unwrap ¶
func (e *NotFoundError) Unwrap() error
type RetryError ¶
RetryError is the required return type of RetryFunc. It forces client code to choose whether or not a given error is retryable.
func NonRetryableError ¶
func NonRetryableError(err error) *RetryError
NonRetryableError is a helper to create a RetryError that's _not_ retryable from a given error. To prevent logic errors, will return an error when passed a nil error.
func RetryableError ¶
func RetryableError(err error) *RetryError
RetryableError is a helper to create a RetryError that's retryable from a given error. To prevent logic errors, will return an error when passed a nil error.
func (*RetryError) Unwrap ¶
func (e *RetryError) Unwrap() error
type RetryFunc ¶
type RetryFunc func() *RetryError
RetryFunc is the function retried until it succeeds.
type StateChangeConf ¶
type StateChangeConf struct { Delay time.Duration // Wait this time before starting checks Pending []string // States that are "allowed" and will continue trying Refresh StateRefreshFunc // Refreshes the current state Target []string // Target state Timeout time.Duration // The amount of time to wait before timeout MinTimeout time.Duration // Smallest time to wait before refreshes PollInterval time.Duration // Override MinTimeout/backoff and only poll this often NotFoundChecks int // Number of times to allow not found (nil result from Refresh) // This is to work around inconsistent APIs ContinuousTargetOccurence int // Number of times the Target state has to occur continuously }
StateChangeConf is the configuration struct used for `WaitForState`.
func (*StateChangeConf) WaitForState
deprecated
func (conf *StateChangeConf) WaitForState() (interface{}, error)
WaitForState watches an object and waits for it to achieve the state specified in the configuration using the specified Refresh() func, waiting the number of seconds specified in the timeout configuration.
Deprecated: Please use WaitForStateContext to ensure proper plugin shutdown
func (*StateChangeConf) WaitForStateContext ¶
func (conf *StateChangeConf) WaitForStateContext(ctx context.Context) (interface{}, error)
WaitForStateContext watches an object and waits for it to achieve the state specified in the configuration using the specified Refresh() func, waiting the number of seconds specified in the timeout configuration.
If the Refresh function returns an error, exit immediately with that error.
If the Refresh function returns a state other than the Target state or one listed in Pending, return immediately with an error.
If the Timeout is exceeded before reaching the Target state, return an error.
Otherwise, the result is the result of the first call to the Refresh function to reach the target state.
Cancellation from the passed in context will cancel the refresh loop
type StateRefreshFunc ¶
StateRefreshFunc is a function type used for StateChangeConf that is responsible for refreshing the item being watched for a state change.
It returns three results. `result` is any object that will be returned as the final object after waiting for state change. This allows you to return the final updated object, for example an EC2 instance after refreshing it. A nil result represents not found.
`state` is the latest state of that object. And `err` is any error that may have happened while refreshing the state.
type TimeoutError ¶
type TimeoutError struct { LastError error LastState string Timeout time.Duration ExpectedState []string }
TimeoutError is returned when WaitForState times out
func (*TimeoutError) Error ¶
func (e *TimeoutError) Error() string
func (*TimeoutError) Unwrap ¶
func (e *TimeoutError) Unwrap() error
type UnexpectedStateError ¶
UnexpectedStateError is returned when Refresh returns a state that's neither in Target nor Pending
func (*UnexpectedStateError) Error ¶
func (e *UnexpectedStateError) Error() string
func (*UnexpectedStateError) Unwrap ¶
func (e *UnexpectedStateError) Unwrap() error