Skip to content

refactor: SentryReporter enabled guard, per-instance unmatched-secondary buffer, deterministic tests#363

Merged
bootjp merged 3 commits into
feature/redis-proxyfrom
copilot/sub-pr-351
Mar 20, 2026
Merged

refactor: SentryReporter enabled guard, per-instance unmatched-secondary buffer, deterministic tests#363
bootjp merged 3 commits into
feature/redis-proxyfrom
copilot/sub-pr-351

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 20, 2026

Four review fixes for the redis-proxy shadow pub/sub and Sentry reporter.

Changes

  • SentryReporter.ShouldReport enabled guard (sentry.go): Add early return false when disabled, eliminating mutex acquisition and map churn on every secondary write when Sentry is not configured. Add injectable nowFunc to the struct.

  • Per-instance unmatchedSecondaries (shadow_pubsub.go): Remove the package-level global sync.Mutex + map[*shadowPubSub]map[...] that serialized buffering/sweeping across all instances. Replaced with a map[msgKey][]secondaryPending field on shadowPubSub itself, protected by the existing sp.mu. Simplifies locking in matchSecondary, reconcileWithBufferedSecondary, sweepExpired, sweepAll, and Close.

  • Remove //nolint:exhaustive (shadow_pubsub.go): Replace the two-branch switch in reportDivergence with an explicit if d.kind == DivExtraData so future DivergenceKind additions are caught at compile/lint time rather than silently falling to a default.

  • Deterministic Sentry cooldown tests (proxy_test.go): TestShouldReportCooldown and TestShouldReportEvictsExpired previously used time.Sleep to wait out cooldown windows. Both now manipulate the injected nowFunc directly:

now := time.Now()
r := &SentryReporter{
    enabled:  true,
    cooldown: 50 * time.Millisecond,
    nowFunc:  func() time.Time { return now },
    ...
}
assert.True(t, r.ShouldReport("fp1"))
assert.False(t, r.ShouldReport("fp1"))   // still within cooldown
now = now.Add(60 * time.Millisecond)      // advance clock, no sleep
assert.True(t, r.ShouldReport("fp1"))    // cooldown elapsed

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

…struct, remove nolint, deterministic tests

Co-authored-by: bootjp <1306365+bootjp@users.noreply.github.com>
Copilot AI changed the title [WIP] Add redis-proxy: dual-write Redis proxy with pub/sub forwarding refactor: SentryReporter enabled guard, per-instance unmatched-secondary buffer, deterministic tests Mar 20, 2026
Copilot AI requested a review from bootjp March 20, 2026 07:02
@bootjp
Copy link
Copy Markdown
Owner

bootjp commented Mar 20, 2026

@copilot fix golangci-lint

Co-authored-by: bootjp <1306365+bootjp@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 20, 2026

@copilot fix golangci-lint

Fixed in 28c1d9b. The gci formatter required double-space alignment before the inline comment on line 311 of proxy_test.go (now = now.Add(60 * time.Millisecond) // advance past cooldown).

@bootjp bootjp marked this pull request as ready for review March 20, 2026 08:03
@bootjp bootjp merged commit 4866d15 into feature/redis-proxy Mar 20, 2026
4 checks passed
@bootjp bootjp deleted the copilot/sub-pr-351 branch March 20, 2026 08:03
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.

2 participants