Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: more reasonable defaults for retry directives #2294

Merged
merged 3 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions backend/schema/metadataretry.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ import (
)

const (
DefaultRetryCount = 100
DefaultRetryCount = 10
MinBackoffLimitStr = "1s"
MinBackoffLimit = 1 * time.Second
DefaultMaxBackoff = 1 * time.Hour
MaxBackoffLimitStr = "1d"
MaxBackoffLimit = 24 * time.Hour
)
Expand Down Expand Up @@ -118,7 +119,7 @@ func (m *MetadataRetry) RetryParams() (RetryParams, error) {

// max backoff
if m.MaxBackoff == "" {
params.MaxBackoff = MaxBackoffLimit
params.MaxBackoff = max(minBackoff, DefaultMaxBackoff)
} else {
maxBackoff, err := parseRetryDuration(m.MaxBackoff)
if err != nil {
Expand Down
4 changes: 1 addition & 3 deletions docs/content/docs/reference/retries.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@ top = false
Any verb called asynchronously (specifically, PubSub subscribers and FSM states), may optionally specify a basic exponential backoff retry policy via a Go comment directive. The directive has the following syntax:

```go
//ftl:retry [<attempts>] <min-backoff> [<max-backoff>] [catch <catchVerb>]
//ftl:retry [<attempts=10>] <min-backoff> [<max-backoff=1hr>] [catch <catchVerb>]
```

`attempts` and `max-backoff` default to unlimited if not specified.

For example, the following function will retry up to 10 times, with a delay of 5s, 10s, 20s, 40s, 60s, 60s, etc.

```go
Expand Down
2 changes: 1 addition & 1 deletion lsp/markdown/completion/retry.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Directive for retrying an async operation.
Any verb called asynchronously (specifically, PubSub subscribers and FSM states), may optionally specify a basic exponential backoff retry policy.

```go
//ftl:retry [<attempts>] <min-backoff> [<max-backoff>]
//ftl:retry [<attempts=10>] <min-backoff> [<max-backoff=1hr>] [catch <catchVerb>]
```

See https://tbd54566975.github.io/ftl/docs/reference/retries/
Expand Down
Loading