# retry.Do extra functionality

**URL:** <https://forum.golangbridge.org/t/retry-do-extra-functionality/31847>\
**Category:** Getting Help\
**Created:** [June 6, 2023, 1:08pm UTC](https://forum.golangbridge.org/t/retry-do-extra-functionality/31847 "2023-06-06T13:08:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![heidi](https://forum.golangbridge.org/user_avatar/forum.golangbridge.org/heidi/32/11592_2.png) [@heidi](https://forum.golangbridge.org/u/heidi)\
**Post date:** [June 6, 2023, 1:08pm UTC](https://forum.golangbridge.org/t/retry-do-extra-functionality/31847/1 "2023-06-06T13:08:19Z")

</div>

Hello fellow gophers,

I want to use _retry.Do_, but would like it to offer me more features. For example, the errors of each retry can only be retrieved together, as a slice, after either a _Do_ has succeeded or it failed the max amount of times.

Secondly, the config paramters (_MaxJitter_, _DelayType_, _MaxRetries_) are configured when you call _Do_, then they remain static. I would like a functionality to be able to start a retry.Do call, then based on its state, to modify these parameters real time.

Is there another package that offers this extra, fine-grained functionality ? How about your usage of _retry.Do_, do you have anything extra that you would like it to offer ?

---

<div class="post-metadata">

**Author:** ![lemarkar](https://forum.golangbridge.org/user_avatar/forum.golangbridge.org/lemarkar/32/12652_2.png) [@lemarkar](https://forum.golangbridge.org/u/lemarkar)\
**Post date:** [June 8, 2023, 10:50am UTC](https://forum.golangbridge.org/t/retry-do-extra-functionality/31847/2 "2023-06-08T10:50:15Z")

</div>

Can you specify what package is this?

---

<div class="post-metadata">

**Author:** ![skillian](https://forum.golangbridge.org/user_avatar/forum.golangbridge.org/skillian/32/7876_2.png) [@skillian](https://forum.golangbridge.org/u/skillian)\
**Post date:** [June 11, 2023, 3:19pm UTC](https://forum.golangbridge.org/t/retry-do-extra-functionality/31847/3 "2023-06-11T15:19:10Z")

</div>

I’m guessing [this](https://pkg.go.dev/github.com/avast/retry-go/v3#section-readme) is the package.

---

<div class="post-metadata">

**Author:** ![skillian](https://forum.golangbridge.org/user_avatar/forum.golangbridge.org/skillian/32/7876_2.png) [@skillian](https://forum.golangbridge.org/u/skillian)\
**Post date:** [June 11, 2023, 3:37pm UTC](https://forum.golangbridge.org/t/retry-do-extra-functionality/31847/4 "2023-06-11T15:37:54Z")

</div>

After reading the source code (and assuming we’re talking about the same package), I suppose you could implement your own `DelayTypeFunc` that delegates to some other delay function:

```auto
type ChangeableDelayType struct {
    Func retry.DelayTypeFunc
}

func (c *ChangeableDelayType) DelayType(n uint, err error, config *Config) time.Duration {
    return c.Func(n, err, config)
}

// ...

c := &ChangeableDelayType{
    Func: retry.BackOfDelay,
}

retry.Do(
    /* ... */,
    retry.DelayType(c.DelayType),
)

// Now you can change c.Func to change the behavior, but be careful
// with concurrent access to c.Func: Maybe add a mutex to
// synchronize access.
```

---

<div class="post-metadata">

**Author:** ![system](https://forum.golangbridge.org/uploads/default/original/2X/5/5ad234f7c3dbc68b6cc72d338ce4f2973d9fd81c.png) [@system](https://forum.golangbridge.org/u/system)\
**Post date:** [September 9, 2023, 3:38pm UTC](https://forum.golangbridge.org/t/retry-do-extra-functionality/31847/5 "2023-09-09T15:38:32Z")

</div>

Closed on September 9, 2023, 3:38pm UTC

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
