feat(backend): implement standardized errors, redis retry strategy, memory stats, and worker shutdown - #766
Merged
Conversation
…ics, and worker shutdown
|
@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! 🚀 |
Collaborator
|
Nice implementation, LGTM! |
|
🎉 This PR is included in version 1.1.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
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.