Option to mock the clock for Closer.reopenCircuitCheck
gavi-anchorlabs opened this issue · comments
Since we're able to configure the Timekeeper
for a Circuit
, it would be helpful if the library also allowed mocking the TimeAfterFunc
of the reopenCircuitCheck
field.
circuit/v3/closers/hystrix/closer.go
Lines 13 to 23 in 700836d
circuit/v3/faststats/timedcheck.go
Line 20 in 700836d
Great library!
What problem are you trying to solve? With most testing, I test hystrix internally to this library and test users of hystrix/circuit by stubbing out their own closer logic.
If you needed to do this, I believe the right way to do this would be to modify this struct ConfigureCloser
with a TimeAfterFunc
parameter.
I'd also like this --
my scenario is that under test, I want to provide a very deterministic clock so that I can focus the test on if my understanding of my configuration matches it's reality, that my fallback gets invoked properly, and that i'm generally using the library correctly.
It was very confusing to me that it wasn't there -- I had configured my circuit with a GeneralConfiguration
providing a time keeper, and the hystrix.Opener
accepts a mock function for Now()
. I spent some time trying to figure out why the circuit in my test was not opening (it's SleepWindow
exceeded the time it took for the test to execute)
happy to put together an MR