Evan Huus ed0319b32e Add code-of-conduct badge to READMEs il y a 10 ans
..
README.md ed0319b32e Add code-of-conduct badge to READMEs il y a 10 ans
breaker.go eaf0b22478 More efficient synchronization il y a 11 ans
breaker_test.go ba556f4cd0 Add test of panic behaviour for 100% statement coverage il y a 11 ans

README.md

circuit-breaker

Build Status GoDoc Code of Conduct

The circuit-breaker resiliency pattern for golang.

Creating a breaker takes three parameters:

  • error threshold (for opening the breaker)
  • success threshold (for closing the breaker)
  • timeout (how long to keep the breaker open)
b := breaker.New(3, 1, 5*time.Second)

for {
	result := b.Run(func() error {
		// communicate with some external service and
		// return an error if the communication failed
		return nil
	})

	switch result {
	case nil:
		// success!
	case breaker.ErrBreakerOpen:
		// our function wasn't run because the breaker was open
	default:
		// some other error
	}
}