cb := circuit.NewThresholdBreaker(10)
events := cb.Subscribe()
go func() {
for {
e := <-events
// Monitor breaker events
}
}()
go cb.Call(func() error {
// A remote call goes here
}, 0)
go cb.Call(func() error {
// Another remote call goes here
}, 0)
I checked the source code [cockroachdb circuitbreaker](
https://github.com/cockroachdb/circuitbreaker). I found that it uses atomic operations and mutexes when updating its fields. So it is possible for the circuitbreaker to support the above usage. But there is documentation mentioning it. And I browsed the CockroachDB source code. It seems that CockroachDB does not use circuit.Breaker concurrently either.