wait

package
v0.17.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 23, 2025 License: Apache-2.0 Imports: 6 Imported by: 26

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RetryHttpErrorStatusCodes = []int{http.StatusBadGateway, http.StatusGatewayTimeout}

Functions

This section is empty.

Types

type AsyncActionCheck

type AsyncActionCheck[T any] func() (waitFinished bool, response *T, err error)

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL