configurable for load and stat statistics logs (#980)

This commit is contained in:
Kevin Wan
2021-08-31 17:14:31 +08:00
committed by GitHub
parent 4bee60eb7f
commit db95b3f0e3
5 changed files with 62 additions and 12 deletions

View File

@@ -31,6 +31,8 @@ var (
// default to be enabled
enabled = syncx.ForAtomicBool(true)
// default to be enabled
logEnabled = syncx.ForAtomicBool(true)
// make it a variable for unit test
systemOverloadChecker = func(cpuThreshold int64) bool {
return stat.CpuUsage() >= cpuThreshold
@@ -80,6 +82,11 @@ func Disable() {
enabled.Set(false)
}
// DisableLog disables the stat logs for load shedding.
func DisableLog() {
logEnabled.Set(false)
}
// NewAdaptiveShedder returns an adaptive shedder.
// opts can be used to customize the Shedder.
func NewAdaptiveShedder(opts ...ShedderOption) Shedder {