You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
aimdcloser is a closer implementation for github.com/cep21/circuit.
It is a closer that increases how many requests it allows in an opened circuit according to
Additive increase/multiplicative decrease
algorithm. The circuit closes when for a configured duration:
No requests have failed
No requests have been not allowed (additive increase is high enough for the rate)
Usage
Have your manager use a ratecloser.CloserFactory and your circuits will be created of this type.
funcExampleCloserFactory() {
// Tell your circuit manager to use the rate limited closerm:= circuit.Manager{
DefaultCircuitProperties: []circuit.CommandPropertiesConstructor{
func(_string) circuit.Config {
return circuit.Config{
General: circuit.GeneralConfig{
OpenToClosedFactory:CloserFactory(CloserConfig{
CloseOnHappyDuration: time.Second*10,
}),
},
}
},
},
}
// Make circuit from managerc:=m.MustCreateCircuit("example_circuit")
// The closer should be a closer of this type_=c.OpenToClose.(*Closer)
// Output:
}