Documentation ¶
Index ¶
- Constants
- func DurationTo8601Seconds(duration time.Duration) string
- func DurationToStringPtr(duration *time.Duration) *string
- func ISO8601StringToDuration(durationStr *string) (*time.Duration, error)
- func Int32ToPtr(val *int32) *int32
- func Retry(ctx context.Context, name string, ...) error
- func WaitForGroupOrContext(ctx context.Context, wg *sync.WaitGroup) error
- type RetryFnArgs
- type RetryOptions
- type SimpleTracer
- func (t *SimpleTracer) FromContext(ctx context.Context) tab.Spanner
- func (t *SimpleTracer) NewContext(parent context.Context, span tab.Spanner) context.Context
- func (t *SimpleTracer) StartSpan(ctx context.Context, operationName string, opts ...interface{}) (context.Context, tab.Spanner)
- func (t *SimpleTracer) StartSpanWithRemoteParent(ctx context.Context, operationName string, carrier tab.Carrier, ...) (context.Context, tab.Spanner)
Constants ¶
const EventRetry = "azsb.Retry"
EventRetry is the name for retry events
const MaxTimeDuration = time.Duration(1<<63 - 1)
straight from 'time.go'
Variables ¶
This section is empty.
Functions ¶
func DurationTo8601Seconds ¶ added in v0.2.0
DurationTo8601Seconds takes a duration and returns a string period of whole seconds (int cast of float)
func DurationToStringPtr ¶ added in v0.2.0
DurationToStringPtr converts a time.Duration to an ISO8601 duration as a string pointer.
func ISO8601StringToDuration ¶ added in v0.2.0
ISO8601StringToDuration converts an ISO8601 string to a Go time.Duration
func Int32ToPtr ¶ added in v0.2.0
func Retry ¶ added in v0.3.4
func Retry(ctx context.Context, name string, fn func(ctx context.Context, args *RetryFnArgs) error, isFatalFn func(err error) bool, o 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 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.
type RetryOptions ¶ added in v0.3.4
type RetryOptions struct { // MaxRetries specifies the maximum number of attempts a failed operation will be retried // before producing an error. // The default value is three. A value less than zero means one try and no retries. MaxRetries int32 // RetryDelay specifies the initial amount of delay to use before retrying an operation. // The delay increases exponentially with each retry up to the maximum specified by MaxRetryDelay. // The default value is four seconds. A value less than zero means no delay between retries. RetryDelay time.Duration // MaxRetryDelay specifies the maximum delay allowed before retrying an operation. // Typically the value is greater than or equal to the value specified in RetryDelay. // The default Value is 120 seconds. A value less than zero means there is no cap. MaxRetryDelay time.Duration }
RetryOptions represent the options for retries.
type SimpleTracer ¶ added in v0.3.2
type SimpleTracer struct {
// contains filtered or unexported fields
}
SimpleTracer is a wrapper around a NoOpTracer so we can add in a really simple stderr logger. Useful for seeing some of the internal state changes (like retries) that aren't normally customer visible. Ex:
tab.Register(&utils.SimpleTracer{ Include: map[string]bool{ tracing.SpanProcessorClose: true, tracing.SpanProcessorLoop: true, tracing.SpanNegotiateClaim: true, tracing.SpanRecover: true, tracing.SpanRecoverLink: true, tracing.SpanRecoverClient: true, }, })
func NewSimpleTracer ¶ added in v0.3.2
func NewSimpleTracer(include map[string]bool, printf func(format string, v ...interface{})) *SimpleTracer
func (*SimpleTracer) FromContext ¶ added in v0.3.2
func (t *SimpleTracer) FromContext(ctx context.Context) tab.Spanner
FromContext creates a stderrSpanner to allow for our stderrLogger to be created.
func (*SimpleTracer) NewContext ¶ added in v0.3.2
NewContext forwards to NoOpTracer.NewContext
func (*SimpleTracer) StartSpan ¶ added in v0.3.2
func (t *SimpleTracer) StartSpan(ctx context.Context, operationName string, opts ...interface{}) (context.Context, tab.Spanner)
StartSpan forwards to NoOpTracer.StartSpan.
func (*SimpleTracer) StartSpanWithRemoteParent ¶ added in v0.3.2
func (t *SimpleTracer) StartSpanWithRemoteParent(ctx context.Context, operationName string, carrier tab.Carrier, opts ...interface{}) (context.Context, tab.Spanner)
StartSpanWithRemoteParent forwards to NoOpTracer.StartSpanWithRemoteParent.