aligned_layer icon indicating copy to clipboard operation
aligned_layer copied to clipboard

feat(aggregator): Extract retry function parameters to a structure

Open Oppen opened this issue 1 year ago • 0 comments

These functions receive a lot of parameters and it is easy to get lost. I would refactor this to receive a struct instead with all the config. This will also make passing a default (which is what we are doing in most if not all retryable functions) much easier, as you would only pass one param and reuse the struct. I'll give you a hint:

type RetryConfig {
MinDelay time.Duration
MaxInterval time.Duration
MaxDelay time.Duration
RetryFactor float64
NumRetries uint64
}

func RetryWithData[T any](functionToRetry func() (T,error), config *RetryConfig) { }

// The you would you use like so 
func foo() {
RetryWithData(funcToRetry, &RetryConfig{ RetryFactor: 5 , ...})
}

Originally posted by @MarcosNicolau in https://github.com/yetanotherco/aligned_layer/pull/1304#discussion_r1835035855

Oppen avatar Nov 11 '24 18:11 Oppen