Open abferm opened 7 years ago
The issue also presents itself in 386 binaries. The issue can be demonstrated by compiling the following code for a 64-bit system and a 32-bit system and running both. Switching the import to my fork will make the code work for both 32-bit and 64-bit systems.
package main
import (
"log"
circuit "github.com/rubyist/circuitbreaker"
)
func main() {
cb := circuit.NewThresholdBreaker(10)
events := cb.Subscribe()
go func() {
for {
e := <-events
// Monitor breaker events like BreakerTripped, BreakerReset, BreakerFail, BreakerReady
log.Println(e)
}
}()
cb.Success()
cb.Fail()
cb.Reset()
}
This library suffers from go issue #599 when compiled for ARM using the gc compiler. The gccgo compiler appears to take care of it, but that limits the go version to <=1.6.1 for official gccgo releases. The following padding & reordering of the Breaker struct fixes the issue.
`// Breaker is the base of a circuit breaker. It maintains failure and success counters // as well as the event subscribers. type Breaker struct { // BackOff is the backoff policy that is used when determining if the breaker should // attempt to retry. A breaker created with NewBreaker will use an exponential backoff // policy by default. BackOff backoff.BackOff
}`