Skip to content

Commit

Permalink
Rename 'RetryType' to 'UnitRetryType'.
Browse files Browse the repository at this point in the history
  • Loading branch information
fr33r committed Jan 16, 2021
1 parent b49c373 commit b218709
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion v4/unit.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func options(options []UnitOption) UnitOptions {
Scope: tally.NoopScope,
Actions: make(map[UnitActionType][]UnitAction),
RetryAttempts: 3,
RetryType: RetryTypeFixed,
RetryType: UnitRetryDelayTypeFixed,
RetryDelay: 50 * time.Millisecond,
RetryMaximumJitter: 50 * time.Millisecond,
}
Expand Down
3 changes: 3 additions & 0 deletions v4/unit/alias.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ type Option = work.UnitOption
// Options represents the configuration options for the work unit.
type Options = work.UnitOptions

// RetryDelayType represents the type of retry delay to perform.
type RetryDelayType = work.UnitRetryDelayType

var (
// DB specifies the option to provide the database for the work unit.
DB = work.UnitDB
Expand Down
24 changes: 12 additions & 12 deletions v4/unit_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,20 @@ type UnitOptions struct {
RetryAttempts int
RetryDelay time.Duration
RetryMaximumJitter time.Duration
RetryType RetryType
RetryType UnitRetryDelayType
}

// UnitOption applies an option to the provided configuration.
type UnitOption func(*UnitOptions)

// RetryType represents the type of retry to perform.
type RetryType int
// UnitRetryDelayType represents the type of retry delay to perform.
type UnitRetryDelayType int

func (t RetryType) convert() retry.DelayTypeFunc {
types := map[RetryType]retry.DelayTypeFunc{
RetryTypeFixed: retry.FixedDelay,
RetryTypeBackOff: retry.BackOffDelay,
RetryTypeRandom: retry.RandomDelay,
func (t UnitRetryDelayType) convert() retry.DelayTypeFunc {
types := map[UnitRetryDelayType]retry.DelayTypeFunc{
UnitRetryDelayTypeFixed: retry.FixedDelay,
UnitRetryDelayTypeBackOff: retry.BackOffDelay,
UnitRetryDelayTypeRandom: retry.RandomDelay,
}
if converted, ok := types[t]; ok {
return converted
Expand All @@ -58,11 +58,11 @@ func (t RetryType) convert() retry.DelayTypeFunc {

const (
// Fixed represents a retry type that maintains a constaint delay between retry iterations.
RetryTypeFixed = iota
UnitRetryDelayTypeFixed = iota
// BackOff represents a retry type that increases delay between retry iterations.
RetryTypeBackOff
UnitRetryDelayTypeBackOff
// Random represents a retry type that utilizes a random delay between retry iterations.
RetryTypeRandom
UnitRetryDelayTypeRandom
)

var (
Expand Down Expand Up @@ -300,7 +300,7 @@ var (
}

// UnitRetryType defines the type of retry to perform.
UnitRetryType = func(retryType RetryType) UnitOption {
UnitRetryType = func(retryType UnitRetryDelayType) UnitOption {
return func(o *UnitOptions) {
o.RetryType = retryType
}
Expand Down

0 comments on commit b218709

Please sign in to comment.