retrypolicy

package
v0.0.0-...-035f276 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action func() error

Action is action function that returns error

type ActionString

type ActionString func() (string, error)

ActionString is action function that returns string and error

type IRetryPolicy

type IRetryPolicy interface {
	// RetryActionString try to execute action that returns string,error
	RetryActionString(action ActionString, handle ShouldRetryOnSpecificError) (value string, err error)
	// RetryAction try to execute action that returns only error
	RetryAction(action Action, handle ShouldRetryOnSpecificError) (err error)
}

IRetryPolicy interface for retrypolicy

type RetryPolicy

type RetryPolicy struct {
	// contains filtered or unexported fields
}

RetryPolicy manages the retry policy of functions.

func NewRetryPolicy

func NewRetryPolicy(instrumentationProvider instrumentation.IInstrumentationProvider, configuration *RetryPolicyConfiguration) *RetryPolicy

NewRetryPolicy Cto'r for retry policy object

func (*RetryPolicy) RetryAction

func (r *RetryPolicy) RetryAction(action Action, shouldRetry ShouldRetryOnSpecificError) (err error)

RetryAction retry to run the action with retryPolicy

func (*RetryPolicy) RetryActionString

func (r *RetryPolicy) RetryActionString(action ActionString, shouldRetry ShouldRetryOnSpecificError) (value string, err error)

RetryActionString retry to run the action with retryPolicy

type RetryPolicyConfiguration

type RetryPolicyConfiguration struct {
	// RetryAttempts  is the number of attempts that the request should be executed.
	RetryAttempts int
	// RetryDuration is the time duration between each retry - in milliseconds
	RetryDurationInMS int
}

RetryPolicyConfiguration is the retry policy configuration that holds the relevant fields for executing retry policy.

func (*RetryPolicyConfiguration) GetBackOffDuration

func (configuration *RetryPolicyConfiguration) GetBackOffDuration() time.Duration

GetBackOffDuration uses the RetryPolicyConfiguration instance's RetryDuration (int) and TimeUnit(string) to a return a time.Duration object of the backoff duration In case of invalid argument, use default values for retry policy.

type ShouldRetryOnSpecificError

type ShouldRetryOnSpecificError func(error) bool

ShouldRetryOnSpecificError is function that gets an error and returns true or false if the retry should handle with this error Returns true in case that retry policy doesn't know how to handle with some error, so it will retry another time (according to the retry attempts and retry count) Returns false in case that the retry policy shouldn't retry another try on error specific error.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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