Documentation
¶
Index ¶
- func BytesFromShortString(s string) []byte
- func BytesFromTime(t time.Time) []byte
- func BytesFromUint32(v uint32) []byte
- func BytesFromUint64(v uint64) []byte
- func IsNetworkError(err error) bool
- func IsRetryableError(err error) bool
- func IsTemporaryError(err error) bool
- func ParseSizeString(sizeStr string) (int, error)
- func Retry(ctx context.Context, config RetryConfig, operation func() error) error
- func RetryWithResult[T any](ctx context.Context, config RetryConfig, operation func() (T, error)) (T, error)
- func ShortStringFromBytes(b []byte) string
- func Uint32FromBytes(b []byte) uint32
- func Uint64FromBytes(b []byte) uint64
- type RetryConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BytesFromShortString ¶
func BytesFromTime ¶
func BytesFromUint32 ¶
func BytesFromUint64 ¶
func IsNetworkError ¶
IsNetworkError returns true if the error appears to be a network error
func IsRetryableError ¶
IsRetryableError combines common retry conditions
func IsTemporaryError ¶
IsTemporaryError returns true if the error appears to be temporary
func ParseSizeString ¶
parseSizeString converts a size string (e.g., "1.5MB", "1024KB") to bytes.
func Retry ¶
func Retry(ctx context.Context, config RetryConfig, operation func() error) error
Retry executes the given function with exponential backoff retry
func RetryWithResult ¶
func RetryWithResult[T any](ctx context.Context, config RetryConfig, operation func() (T, error)) (T, error)
RetryWithResult executes the given function with exponential backoff retry and returns the result
func ShortStringFromBytes ¶
func Uint32FromBytes ¶
func Uint64FromBytes ¶
Types ¶
type RetryConfig ¶
type RetryConfig struct {
// MaxAttempts is the maximum number of retry attempts
MaxAttempts int
// InitialBackoff is the initial backoff duration
InitialBackoff time.Duration
// MaxBackoff is the maximum backoff duration
MaxBackoff time.Duration
// BackoffFactor is the factor by which the backoff increases
BackoffFactor float64
// RetryableErrors is a function that determines if an error is retryable
RetryableErrors func(error) bool
}
RetryConfig holds the configuration for retry operations
func DefaultRetryConfig ¶
func DefaultRetryConfig() RetryConfig
DefaultRetryConfig returns a default retry configuration
Click to show internal directories.
Click to hide internal directories.