Sign in

    moonbitstack/moonzero/shedder does not have a README file

    Shedder

    pub struct Shedder {
    threshold : Int64
    usage : () -> Int64
    }

    Load shedding under CPU pressure (← go-zero's load.AdaptiveShedder, wired from RestConf.CpuThreshold): admit while measured CPU sits at or below the threshold, shed above it. Both numbers are per-mille, so go-zero's default 900 means 90%.

    go-zero reads stat.CpuUsage() and additionally sheds on in-flight count against a moving pass/latency estimate. No MoonBit backend can read a CPU meter, so the usage source is injected the way Clock is, and a shedder built without one reports 0 and never sheds — the in-flight half is not modelled.

    Shedder::allow

    fn Shedder::allow(self : Shedder) -> Bool

    Whether a request is admitted at the current usage.

    Shedder::new

    fn Shedder::new(threshold : Int64, usage? : () -> Int64) -> Shedder

    A shedder that sheds once usage exceeds threshold per-mille.

    Shedder::usage

    fn Shedder::usage(self : Shedder) -> Int64

    The CPU usage the shedder is reading, per mille.

    Source Files