go test -timeout 2400s -run ^Test_kiwf_Impl_3$ github.com/thisisdevelopment/kiwf -count=10000
These test fails sometimes
Kill It With Fire ๐ฅ ๐ซ is an advanced, yet simple internal heartbeat library for golang. The library removes the need to implement your own timeout procedures using ctx/timeout/deadline/cancel routines. Timeout, delay and startup time can be configured. Also there's a possibility to pass in a map[string]interface{} that will be passed into a configurable ExitFunction. If no ExitFunction is configured a panic will be generated.
// initialize
kiwf, err := New("my work", &Config{
// delay for sometime to start monitoring
DelayStartupTime: 10 * time.Millisecond,
// duration we should kill or call function if we didnt receive a Tick in time
Timeout: 150 * time.Millisecond,
})
if err != nil {
// do sth with err
}
// start watching
kiwf.Start()
// always call Close
defer kiwf.Close()
testTimeout := 500 * time.Millisecond
startTime := time.Now()
// simulate some work for approx 500ms and timeout
for {
kiwf.Tick()
if time.Since(startTime) > testTimeout {
break
}
time.Sleep(1 * time.Millisecond)
}
// simulate idleness, do nothing, take a nap
time.Sleep(time.Second)
// this should panic vvvv
panic: Killed it with fire 'my work' time expired last action 150.833542ms ago. set timeout 150ms. passtru vars map[], time obj 2022-12-14 11:11:08.212809 +0100 CET m=+0.501677876
You can help to deliver a better fire ๐ฅ ๐ซ killer, check out how you can do things CONTRIBUTING.md
ยฉ This is Development BV, 2022~time.Now() Released under the MIT License