Skip to content

feat(backend): implement standardized errors, redis retry strategy, memory stats, and worker shutdown - #766

Merged
adams813 merged 2 commits into
benelabs:mainfrom
Dopezapha:feature/backend-enhancements
Aug 2, 2026
Merged

feat(backend): implement standardized errors, redis retry strategy, memory stats, and worker shutdown#766
adams813 merged 2 commits into
benelabs:mainfrom
Dopezapha:feature/backend-enhancements

Conversation

@Dopezapha

Copy link
Copy Markdown
Contributor

Closes #731
Closes #732
Closes #733
Closes #734

PR Description

I resolved four backend issues on the Crucible smart contract testing platform: implementing worker graceful shutdown handlers, standardizing API error response formats, setting up a Redis connection retry strategy, and adding memory metrics tracking.

For issue #731, I exposed the executor and scheduler modules under the workers directory. I built a shutdown coordinator struct using watch channels and join handles to track background worker tasks. I registered SIGINT and SIGTERM signal handles to monitor OS calls and trigger graceful worker shutdowns before the process exits. I also added unit tests verifying that running worker tasks are given time to drain and complete within their grace period.

For issue #732, I created a new errors handler containing a standardized JSON schema with code, message, and timestamp. I routed fallback 404 paths to this schema and updated Authentication, Permission, and Rate Limiting middlewares to return this format instead of plain text. I also updated the main application error converter and the API result contract responses to include chrono Utc timestamps.

For issue #733, I implemented a connection manager retry helper using exponential backoff delay starting at 100ms up to 5s. I configured connection timeouts based on existing Redis parameters. I replaced the standard connection establishment calls at startup in main to prevent service crashes on transient failures.

For issue #734, I updated the system metrics tracker to extract the real Resident Set Size and Heap Allocation segment bytes from the local Linux proc self status file. I exposed the resident memory size to the Prometheus exposition handler endpoints.

Changes Made

Testing

  • Checked compilation via cargo check. The custom implementations compile correctly.
  • Checked unit tests using cargo test.
    Note: The local test run encountered a pre-existing system linkage error in backend/src/services/audit.rs due to missing pkg config / OpenSSL headers on the host environment, which was left out of scope per instruction.

@drips-wave

drips-wave Bot commented Jul 29, 2026

Copy link
Copy Markdown

@Dopezapha 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

@adams813

adams813 commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator

Nice implementation, LGTM!

@adams813
adams813 merged commit 3d6e963 into benelabs:main Aug 2, 2026
2 of 12 checks passed
@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 1.1.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

2 participants