https://github.com/honestbank/backoff-policy
Terraform-managed repo.
https://github.com/honestbank/backoff-policy
workspace-code-infrastructure-prod
Last synced: 4 months ago
JSON representation
Terraform-managed repo.
- Host: GitHub
- URL: https://github.com/honestbank/backoff-policy
- Owner: honestbank
- Created: 2021-11-15T03:14:23.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2026-01-28T09:01:17.000Z (4 months ago)
- Last Synced: 2026-01-28T22:38:01.986Z (4 months ago)
- Topics: workspace-code-infrastructure-prod
- Language: Shell
- Homepage:
- Size: 60.5 KB
- Stars: 0
- Watchers: 23
- Forks: 1
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# backoff-policy
In order to help developers wait if things are failing, this library aims to provide some useful methods.
The idea is that, you start a policy, in a loop, you do some work, if this fails, you mark it failed, if it passes, you mark it success.
This library will take care of delaying the work.
Code ideation:
```go
package main
import (
"time"
"github.com/honestbank/backoff-policy"
)
func process() error {
// do work?
return nil
}
func main() {
policy := backoff_policy.NewExponentialBackoffPolicy(time.Millisecond * 100, 15)
queue := getQueue()
for ; ; {
policy.Execute(func(marker backoff_policy.Marker) {
message := queue.GetNewMessage()
err := process(message)
if err != nil {
marker.MarkFailure()
// log something, obviously...
return
}
// queue.Ack(message)
marker.MarkSuccess()
})
}
}
```