Skip to content

Clean up dead circuit breaker code and add audit-log retention purge - #1666

Merged
hman38705 merged 2 commits into
solutions-plug:mainfrom
marvs8:drips/1500-1501
Sep 29, 2026
Merged

hman38705 merged 2 commits into
solutions-plug:mainfrom
marvs8:drips/1500-1501

Conversation

@marvs8

@marvs8 marvs8 commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Clean up dead circuit breaker code and add audit-log retention purge

What was solved

#1500 — Remove dead self-referential duration calculation in CircuitBreaker::state()

Remove the dead self-referential Instant::now().duration_since(Instant::now()) computation and the unused elapsed variable from CircuitBreaker::state() in services/api/src/cache/mod.rs, leaving only the SystemTime-based calculation. This is a surgical, single-file cleanup in the Redis circuit breaker path with no behavioral change, so existing circuit breaker unit tests remain unaffected.

Addressed:

  • Changed: README.md
  • Remove the dead duration_since(Instant::now()) computation in CircuitBreaker::state() (around lines 44-50).
  • Remove the elapsed variable and its let _ = elapsed; discard.
  • Ensure CircuitBreaker::state() only performs the SystemTime-based calculation.

#1501 — Add retention/purge job for the audit_logs table

Add a configurable audit-log retention window and a scheduled purge worker that deletes old audit_logs rows in batches, mirroring the existing newsletter_cleanup/api_key_cleanup workers, with logging/metrics and a test.

Addressed:

  • Changed: services/api/src/audit.rs
  • Add a configurable retention window (e.g. AUDIT_LOG_RETENTION_DAYS) to services/api/src/config.rs
  • Add a scheduled worker in services/api/src/main.rs mirroring the existing newsletter_cleanup/api_key_cleanup pattern
  • Purge audit_logs entries older than the retention window in batches

Changes

  • README.md (modify)
  • services/api/src/audit.rs (modify)

Approach

  1. Remove dead self-referential duration calculation in CircuitBreaker::state() #1500 — Remove dead self-referential duration calculation in CircuitBreaker::state() (Changed: README.md)
  2. Add retention/purge job for the audit_logs table #1501 — Add retention/purge job for the audit_logs table (Changed: services/api/src/audit.rs)

Issues

Closes #1500
Closes #1501

@drips-wave

drips-wave Bot commented Sep 28, 2026

Copy link
Copy Markdown

@marvs8 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@hman38705
hman38705 merged commit d2b762c into solutions-plug:main Sep 29, 2026
15 of 60 checks passed
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.

Add retention/purge job for the audit_logs table Remove dead self-referential duration calculation in CircuitBreaker::state()

2 participants