Skip to content

Replace jitterbug with stdlib jitter - #9

Open
ivanauth wants to merge 4 commits into
authzed:mainfrom
ivanauth:fix/crdbpool-issue-8-replace-jitterbug
Open

ivanauth wants to merge 4 commits into
authzed:mainfrom
ivanauth:fix/crdbpool-issue-8-replace-jitterbug

Conversation

@ivanauth

@ivanauth ivanauth commented Feb 9, 2026 •

Copy link
Copy Markdown

Replaces the jitterbug dependency with stdlib time.After + math/rand for health check poll jitter.

Fixes #8

@ecordell ecordell left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Comment thread pkg/health.go Outdated
@ivanauth
ivanauth force-pushed the fix/crdbpool-issue-8-replace-jitterbug branch from 93dadbe to 2081927 Compare February 10, 2026 18:53
The jitterbug ticker was configured as Uniform{Min: interval} against a
base interval of the same length. jitterbug computes the delay as
max(rand.Int63n(interval), Min), and the draw is always less than
interval, so every "jittered" poll fired at exactly the interval. Health
checks had no jitter at all.

Poll now uses a reusable time.Timer, which also avoids allocating a new
channel on every tick, and jitteredInterval offsets each tick by a
uniformly random amount in [-interval/2, +interval/2). The distribution
is centered on the requested interval and is covered by a unit test. A
non-positive interval now disables polling instead of panicking in
rand.Int63n.

Dropping the dependency required updating the toolchain: govulncheck
reported 13 vulnerabilities across the Go standard library,
google.golang.org/grpc, golang.org/x/text and github.com/jackc/pgx/v5.
CI moves to Go ~1.26.5, grpc to v1.82.1, x/text to v0.39.0 and pgx to
v5.9.2, which clears all of them. go mod tidy raises the module's Go
directive to 1.25.0, so the magefiles workspace is bumped to match.

pgx v5.9.2 deprecates pgxpool BeforeAcquire in favor of PrepareConn, and
PrepareConn takes precedence when both are set, so the wrapper now
installs PrepareConn while still honoring a caller-supplied
BeforeAcquire as a fallback.

Fixes authzed#8
@ivanauth
ivanauth force-pushed the fix/crdbpool-issue-8-replace-jitterbug branch from ed38f7f to b7d0829 Compare July 28, 2026 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

replace jitterbug

2 participants