Documentation
¶
Index ¶
- Variables
- type AsyncActionCheck
- type AsyncActionHandler
- func (h *AsyncActionHandler[T]) SetSleepBeforeWait(d time.Duration) *AsyncActionHandler[T]
- func (h *AsyncActionHandler[T]) SetTempErrRetryLimit(l int) *AsyncActionHandler[T]
- func (h *AsyncActionHandler[T]) SetThrottle(d time.Duration) *AsyncActionHandler[T]
- func (h *AsyncActionHandler[T]) SetTimeout(d time.Duration) *AsyncActionHandler[T]
- func (h *AsyncActionHandler[T]) WaitWithContext(ctx context.Context) (res *T, err error)
- type WaiterHelper
Constants ¶
This section is empty.
Variables ¶
var RetryHttpErrorStatusCodes = []int{http.StatusBadGateway, http.StatusGatewayTimeout}
Functions ¶
This section is empty.
Types ¶
type AsyncActionCheck ¶
AsyncActionCheck reports whether a specific async action has finished.
- waitFinished == true if the async action is finished, false otherwise.
- response contains data regarding the current state of the resource targeted by the async action, if applicable. If not applicable, T should be struct{}.
- err != nil if there was an error checking if the async action finished, or if it finished unsuccessfully.
type AsyncActionHandler ¶
type AsyncActionHandler[T any] struct { IntermediateStateReached bool // contains filtered or unexported fields }
AsyncActionHandler handles waiting for a specific async action to be finished.
func New ¶
func New[T any](f AsyncActionCheck[T]) *AsyncActionHandler[T]
New initializes an AsyncActionHandler
func (*AsyncActionHandler[T]) SetSleepBeforeWait ¶
func (h *AsyncActionHandler[T]) SetSleepBeforeWait(d time.Duration) *AsyncActionHandler[T]
SetSleepBeforeWait sets the duration for sleep before wait.
func (*AsyncActionHandler[T]) SetTempErrRetryLimit ¶
func (h *AsyncActionHandler[T]) SetTempErrRetryLimit(l int) *AsyncActionHandler[T]
SetTempErrRetryLimit sets the retry limit if a temporary error is found. The list of temporary errors is defined in the RetryHttpErrorStatusCodes variable.
func (*AsyncActionHandler[T]) SetThrottle ¶
func (h *AsyncActionHandler[T]) SetThrottle(d time.Duration) *AsyncActionHandler[T]
SetThrottle sets the time interval between each check of the async action.
func (*AsyncActionHandler[T]) SetTimeout ¶
func (h *AsyncActionHandler[T]) SetTimeout(d time.Duration) *AsyncActionHandler[T]
SetTimeout sets the duration for wait timeout.
func (*AsyncActionHandler[T]) WaitWithContext ¶
func (h *AsyncActionHandler[T]) WaitWithContext(ctx context.Context) (res *T, err error)
WaitWithContext starts the wait until there's an error or wait is done
type WaiterHelper ¶ added in v0.23.0
type WaiterHelper[T any, S comparable] struct { // FetchInstance is called periodically to get the latest resource data. FetchInstance func() (*T, error) // GetState extracts the status string from the API response. GetState func(*T) (S, error) // ActiveState represents the terminal "Happy Path" (e.g. ACTIVE, READY, CREATED). ActiveState []S // ErrorState represents the terminal "Error Path" (e.g. FAILED, ERROR). ErrorState []S // DeleteHttpErrorStatusCodes defines codes treated as a successful deletion (default: 403, 404, 410). DeleteHttpErrorStatusCodes []int }
WaiterHelper is a helper struct, which creates based on the configured attributes the AsyncActionCheck for wait.New
func (*WaiterHelper[T, S]) Wait ¶ added in v0.23.0
func (w *WaiterHelper[T, S]) Wait() AsyncActionCheck[T]