utils

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const EventRetry = "azsb.Retry"

EventRetry is the name for retry events

View Source
const MaxTimeDuration = time.Duration(1<<63 - 1)

straight from 'time.go'

Variables

This section is empty.

Functions

func DurationTo8601Seconds added in v0.2.0

func DurationTo8601Seconds(duration time.Duration) string

DurationTo8601Seconds takes a duration and returns a string period of whole seconds (int cast of float)

func DurationToStringPtr added in v0.2.0

func DurationToStringPtr(duration *time.Duration) *string

DurationToStringPtr converts a time.Duration to an ISO8601 duration as a string pointer.

func ISO8601StringToDuration added in v0.2.0

func ISO8601StringToDuration(durationStr *string) (*time.Duration, error)

ISO8601StringToDuration converts an ISO8601 string to a Go time.Duration

func Int32ToPtr added in v0.2.0

func Int32ToPtr(val *int32) *int32

func Retry added in v0.3.4

func Retry(ctx context.Context, eventName log.Event, operation string, fn func(ctx context.Context, args *RetryFnArgs) error, isFatalFn func(err error) bool, o exported.RetryOptions) error

Retry runs a standard retry loop. It executes your passed in fn as the body of the loop. It returns if it exceeds the number of configured retry options or if 'isFatal' returns true.

Types

type Logger added in v1.3.0

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

func NewLogger added in v1.3.0

func NewLogger() Logger

func (*Logger) Prefix added in v1.3.0

func (l *Logger) Prefix() string

func (*Logger) SetPrefix added in v1.3.0

func (l *Logger) SetPrefix(format string, args ...any)

func (*Logger) Writef added in v1.3.0

func (l *Logger) Writef(evt azlog.Event, format string, args ...any)

type RetryFnArgs added in v0.3.4

type RetryFnArgs struct {
	// I is the iteration of the retry "loop" and starts at 0.
	// The 0th iteration is the first call, and doesn't count as a retry.
	// The last try will equal RetryOptions.MaxRetries
	I int32
	// LastErr is the returned error from the previous loop.
	// If you have potentially expensive
	LastErr error
	// contains filtered or unexported fields
}

func (*RetryFnArgs) ResetAttempts added in v0.3.4

func (rf *RetryFnArgs) ResetAttempts()

ResetAttempts resets all Retry() attempts, starting back at iteration 0.

Jump to

Keyboard shortcuts

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