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)
Constants ¶
This section is empty.
Variables ¶
View Source
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
Click to show internal directories.
Click to hide internal directories.