circuitbreaker alternatives and similar packages
Based on the "Utilities" category.
Alternatively, view circuitbreaker alternatives based on common mentions on social networks and blogs.
-
项目文档
基于vite+vue3+gin搭建的开发基础平台(支持TS,JS混用),集成jwt鉴权,权限管理,动态路由,显隐可控组件,分页封装,多点登录拦截,资源权限,上传下载,代码生成器,表单生成器,chatGPT自动查表等开发必备功能。 -
excelize
Go language library for reading and writing Microsoft Excel™ (XLAM / XLSM / XLSX / XLTM / XLTX) spreadsheets -
godotenv
A Go port of Ruby's dotenv library (Loads environment variables from .env files) -
godropbox
Common libraries for writing Go services/applications. -
Kopia
Cross-platform backup tool for Windows, macOS & Linux with fast, incremental backups, client-side end-to-end encryption, compression and data deduplication. CLI and GUI included. -
hystrix-go
Netflix's Hystrix latency and fault tolerance library, for Go -
go-funk
A modern Go utility library which provides helpers (map, find, contains, filter, ...) -
gorequest
GoRequest -- Simplified HTTP client ( inspired by nodejs SuperAgent ) -
goreporter
A Golang tool that does static analysis, unit testing, code review and generate code quality report. -
lancet
A comprehensive, efficient, and reusable util function library of Go. -
gojson
Automatically generate Go (golang) struct definitions from example JSON -
create-go-app
✨ A complete and self-contained solution for developers of any qualification to create a production-ready project with backend (Go), frontend (JavaScript, TypeScript) and deploy automation (Ansible, Docker) by running only one CLI command. -
spinner
Go (golang) package with 90 configurable terminal spinner/progress indicators. -
EaseProbe
A simple, standalone, and lightweight tool that can do health/status checking, written in Go. -
filetype
Fast, dependency-free Go package to infer binary file types based on the magic numbers header signature -
boilr
:zap: boilerplate template manager that generates files or directories from template repositories -
sling
A Go HTTP client library for creating and sending API requests -
mole
CLI application to create ssh tunnels focused on resiliency and user experience. -
beaver
💨 A real time messaging system to build a scalable in-app notifications, multiplayer games, chat apps in web and mobile apps. -
mimetype
A fast Golang library for media type and file extension detection, based on magic numbers -
go-underscore
Helpfully Functional Go - A useful collection of Go utilities. Designed for programmer happiness. -
JobRunner
Framework for performing work asynchronously, outside of the request flow -
scany
Library for scanning data from a database into Go structs and more -
git-time-metric
Simple, seamless, lightweight time tracking for Git
Learn any GitHub repo in 59 seconds
Do you think we are missing an alternative of circuitbreaker or a related project?
README
circuitbreaker
Circuitbreaker provides an easy way to use the Circuit Breaker pattern in a Go program.
Circuit breakers are typically used when your program makes remote calls. Remote calls can often hang for a while before they time out. If your application makes a lot of these requests, many resources can be tied up waiting for these time outs to occur. A circuit breaker wraps these remote calls and will trip after a defined amount of failures or time outs occur. When a circuit breaker is tripped any future calls will avoid making the remote call and return an error to the caller. In the meantime, the circuit breaker will periodically allow some calls to be tried again and will close the circuit if those are successful.
You can read more about this pattern and how it's used at:
Installation
go get github.com/rubyist/circuitbreaker
Examples
Here is a quick example of what circuitbreaker provides
// Creates a circuit breaker that will trip if the function fails 10 times
cb := circuit.NewThresholdBreaker(10)
events := cb.Subscribe()
go func() {
for {
e := <-events
// Monitor breaker events like BreakerTripped, BreakerReset, BreakerFail, BreakerReady
}
}()
cb.Call(func() error {
// This is where you'll do some remote call
// If it fails, return an error
}, 0)
Circuitbreaker can also wrap a time out around the remote call.
// Creates a circuit breaker that will trip after 10 failures
// using a time out of 5 seconds
cb := circuit.NewThresholdBreaker(10)
cb.Call(func() error {
// This is where you'll do some remote call
// If it fails, return an error
}, time.Second * 5) // This will time out after 5 seconds, which counts as a failure
// Proceed as above
Circuitbreaker can also trip based on the number of consecutive failures.
// Creates a circuit breaker that will trip if 10 consecutive failures occur
cb := circuit.NewConsecutiveBreaker(10)
// Proceed as above
Circuitbreaker can trip based on the error rate.
// Creates a circuit breaker based on the error rate
cb := circuit.NewRateBreaker(0.95, 100) // trip when error rate hits 95%, with at least 100 samples
// Proceed as above
If it doesn't make sense to wrap logic in Call(), breakers can be handled manually.
cb := circuit.NewThresholdBreaker(10)
for {
if cb.Ready() {
// Breaker is not tripped, proceed
err := doSomething()
if err != nil {
cb.Fail() // This will trip the breaker once it's failed 10 times
continue
}
cb.Success()
} else {
// Breaker is in a tripped state.
}
}
Circuitbreaker also provides a wrapper around http.Client
that will wrap a
time out around any request.
// Passing in nil will create a regular http.Client.
// You can also build your own http.Client and pass it in
client := circuit.NewHTTPClient(time.Second * 5, 10, nil)
resp, err := client.Get("http://example.com/resource.json")
See the godoc for more examples.
Bugs, Issues, Feedback
Right here on GitHub: https://github.com/rubyist/circuitbreaker