A simple and flexible Go library for implementing retry mechanisms with configurable backoff strategies and error handling.
retry-go is a Go library that implements a retry mechanism for operations that may fail intermittently. It provides a simple API to automatically retry failed function calls with configurable attempts, delays, and backoff strategies, helping developers build more resilient applications.
Go developers building applications that interact with external services, networks, or other unreliable systems where transient failures are common.
Developers choose retry-go for its clean, intuitive API, performance optimizations like reusable retriers, and extensive customization options including multiple delay strategies and fine-grained error control, all while maintaining simplicity.
Simple golang library for retry mechanism
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
The v5 redesign uses an intuitive retry.New().Do() syntax, simplifying integration as shown in HTTP examples, moving away from the older functional options pattern.
Creating retrier instances once minimizes allocations in success cases, optimizing high-frequency operations, as highlighted in the reusable retrier example.
Supports fixed, exponential backoff, random jitter, and custom DelayTypeFunc, enabling precise control over retry timing through functions like FullJitterBackoffDelay.
Features like Unrecoverable() and RetryIf() allow marking errors as non-retryable and filtering retry conditions, with detailed examples in the README.
Multiple major version updates (v5, v4, v3) with API redesigns, such as switching to method-based calls and changing error unwrapping, can break existing code and require migration efforts.
In v5, Unwrap() returns []error instead of a single error, complicating error inspection compared to standard Go practices and requiring adaptation with LastError() or errors.Is.
Creating custom DelayTypeFunc requires understanding the DelayContext interface, adding complexity for advanced use cases beyond the built-in strategies.