func (r *rudimentaryErrorBackoff) OnError(error) {
	r.lastErrorTimeLock.Lock()
	defer r.lastErrorTimeLock.Unlock()
	d := time.Since(r.lastErrorTime)
	if d < r.minPeriod {
		time.Sleep(r.minPeriod - d)
	}
	r.lastErrorTime = time.Now()
}
OnError will block if it is called more often than the embedded period time.
This will prevent overly tight hot error loops.
package runtime
import (
	"fmt"
	"runtime"
	"sync"
	"time"
	"k8s.io/klog"
)
var (
	ReallyCrash = true
)
var PanicHandlers = []func(interface{}){logPanic}
func HandleCrash(additionalHandlers ...func(interface{})) {
	if r := recover(); r != nil {
		for _, fn := range PanicHandlers {
			fn(r)
		}
		for _, fn := range additionalHandlers {
			fn(r)
		}
		if ReallyCrash {
			panic(r)
		}
	}
}
func logPanic(r interface{}) {
	const size = 64 << 10
	stacktrace := make([]byte, size)
	stacktrace = stacktrace[:runtime.Stack(stacktrace, false)]
	if _, ok := r.(string); ok {
		klog.Errorf("Observed a panic: %s\n%s", r, stacktrace)
	} else {
		klog.Errorf("Observed a panic: %#v (%v)\n%s", r, r, stacktrace)
	}
}
var ErrorHandlers = []func(error){
	logError,
	(&rudimentaryErrorBackoff{
		lastErrorTime: time.Now(),
		minPeriod: time.Millisecond,
	}).OnError,
}
func HandleError(err error) {
	if err == nil {
		return
	}
	for _, fn := range ErrorHandlers {
		fn(err)
	}
}
func logError(err error) {
	klog.ErrorDepth(2, err)
}
type rudimentaryErrorBackoff struct {
	minPeriod time.Duration  
	lastErrorTimeLock sync.Mutex
	lastErrorTime     time.Time
}