diff options
| author | Xe Iaso <me@xeiaso.net> | 2023-08-26 14:14:51 -0400 |
|---|---|---|
| committer | Xe Iaso <me@xeiaso.net> | 2023-08-26 14:14:51 -0400 |
| commit | 81fe4e8a12b362f7de9a97210f950c388d047664 (patch) | |
| tree | d71d879f62d74e528a1338470df268669e2565be /cardio | |
| parent | 924a12ab6915b7dad147ed57c5a384c142f82c1e (diff) | |
| download | x-81fe4e8a12b362f7de9a97210f950c388d047664.tar.xz x-81fe4e8a12b362f7de9a97210f950c388d047664.zip | |
Switch from ln to slog
ln had a good run, but it's not going to last for the long term. I'm
going to standardize everything on log/slog and deprecate ln.
Closes #385
Signed-off-by: Xe Iaso <me@xeiaso.net>
Diffstat (limited to 'cardio')
| -rw-r--r-- | cardio/cardio.go | 28 |
1 files changed, 0 insertions, 28 deletions
diff --git a/cardio/cardio.go b/cardio/cardio.go index 15343dd..c54dd34 100644 --- a/cardio/cardio.go +++ b/cardio/cardio.go @@ -3,11 +3,8 @@ package cardio import ( "context" - "expvar" "sync" "time" - - "within.website/ln/opname" ) // Heartbeat is a function that creates a "heartbeat" channel that you can influence to go faster @@ -37,31 +34,11 @@ import ( // // This will let you have a dynamically adjusting heartbeat for when your sick, twisted desires // demand it. -// -// If you are using ln's opname facility (https://pkg.go.dev/within.website/ln/opname), then an -// expvar gauge will be created that will contain the current heartbeat. This allows you to -// monitor and alert on this value changing erratically. func Heartbeat(ctx context.Context, min, max time.Duration) (<-chan struct{}, func(), func()) { heartbeat := make(chan struct{}, 1) // output channel currDelay := max // start at max speed var currDelayLock sync.Mutex - var counter *expvar.Int - var tachycardiaCounter *expvar.Int - - if name, ok := opname.Get(ctx); ok { - if ctr := expvar.Get("gauge_heartbeat_" + name); counter == nil { - counter = expvar.NewInt("gauge_heartbeat_" + name) - } else { - counter = ctr.(*expvar.Int) - } - if ctr := expvar.Get("gauge_heartbeat_backoff_" + name); tachycardiaCounter == nil { - tachycardiaCounter = expvar.NewInt("gauge_heartbeat_backoff_" + name) - } else { - tachycardiaCounter = ctr.(*expvar.Int) - } - } - slower := func() { currDelayLock.Lock() currDelay = currDelay / 2 @@ -92,14 +69,9 @@ func Heartbeat(ctx context.Context, min, max time.Duration) (<-chan struct{}, fu currDelayLock.Unlock() time.Sleep(toSleep) - if counter != nil { - counter.Set(int64(toSleep)) - } - select { case heartbeat <- struct{}{}: default: - tachycardiaCounter.Add(1) slower() // back off if the channel is full } } |
