Hiya fellow gophers,
I need to use retry.Do, however would really like it to supply me extra options. For instance, the errors of every retry can solely be retrieved collectively, as a slice, after both a Do has succeeded or it failed the max quantity of instances.
Secondly, the config paramters (MaxJitter, DelayType, MaxRetries) are configured once you name Do, then they continue to be static. I would really like a performance to have the ability to begin a retry.Do name, then based mostly on its state, to switch these parameters actual time.
Is there one other package deal that gives this additional, fine-grained performance ? How about your utilization of retry.Do, do you will have something additional that you prefer to it to supply ?
Are you able to specify what package deal is that this?
I’m guessing this is the package deal.
After studying the supply code (and assuming we’re speaking about the identical package deal), I suppose you could possibly implement your personal DelayTypeFunc
that delegates to another delay operate:
sort ChangeableDelayType struct {
Func retry.DelayTypeFunc
}
func (c *ChangeableDelayType) DelayType(n uint, err error, config *Config) time.Length {
return c.Func(n, err, config)
}
// ...
c := &ChangeableDelayType{
Func: retry.BackOfDelay,
}
retry.Do(
/* ... */,
retry.DelayType(c.DelayType),
)
// Now you possibly can change c.Func to alter the habits, however watch out
// with concurrent entry to c.Func: Possibly add a mutex to
// synchronize entry.