From 81fe4e8a12b362f7de9a97210f950c388d047664 Mon Sep 17 00:00:00 2001 From: Xe Iaso Date: Sat, 26 Aug 2023 14:14:51 -0400 Subject: 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 --- cardio/cardio.go | 28 ---------------------------- 1 file changed, 28 deletions(-) (limited to 'cardio') 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 } } -- cgit v1.2.3