feat: Phase 7.1 - Integrate Retry Logic in ProcessWorker#145
Merged
feat: Phase 7.1 - Integrate Retry Logic in ProcessWorker#145
Conversation
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.
📝 Description
Implements comprehensive retry logic in ProcessWorker to handle transient failures with exponential backoff and coordinated message redelivery through RabbitMQ.
Closes #102
🎯 Changes Made
Core Implementation
RetryConfigurationclass with exponential backoff calculationProcessWorker.HandleProcessFailureAsyncPublishRetryMessageAsyncmethod for delayed message publishingRetryConfigurationConfiguration
appsettings.jsonwith retry configurationappsettings.Development.jsonwith dev-specific settingsProgram.csto registerRetryConfigurationTesting
RetryLogicTests)Documentation
docs/RETRY-LOGIC.mdwith complete implementation guide🛠️ Technical Details
Exponential Backoff Formula
Example with defaults:
Jitter Implementation
Adds ±30% randomization to prevent thundering herd:
Error Classification
Retryable:
TimeoutExceptionHttpRequestExceptionOperationCanceledException(graceful shutdown)Non-Retryable:
InvalidOperationException(business logic violations)NO_HANDLER_FOUNDRetry Flow
ProcessService.FailProcessAsync(canRetry)RetryCountvsMaxRetries📋 Files Changed
New Files
src/StarGate.Core/Configuration/RetryConfiguration.cssrc/StarGate.Server/appsettings.jsonsrc/StarGate.Server/appsettings.Development.jsontests/StarGate.Server.Tests/Workers/RetryLogicTests.csdocs/RETRY-LOGIC.mdModified Files
src/StarGate.Server/Workers/ProcessWorker.csIMessageBrokerandRetryConfigurationdependenciesHandleProcessFailureAsyncwith retry decision logicPublishRetryMessageAsyncmethodsrc/StarGate.Server/Program.csRetryConfigurationregistration✅ Testing
Unit Tests
All retry logic unit tests pass:
Test Coverage:
Integration Testing Plan
docker-compose up -dmaxRetries: 3FailedretryCount = 3in process📚 Documentation
Comprehensive documentation added in
docs/RETRY-LOGIC.md:🔗 Dependencies
Depends On
Related To
⚙️ Configuration
Production (
appsettings.json){ "Retry": { "BaseDelaySeconds": 5, "MaxDelaySeconds": 300, "BackoffMultiplier": 2.0, "UseJitter": true } }Development (
appsettings.Development.json){ "Retry": { "BaseDelaySeconds": 3, "MaxDelaySeconds": 60, "BackoffMultiplier": 2.0, "UseJitter": true } }🐛 Known Issues / Limitations
None. Implementation follows issue #102 specifications completely.
📝 Checklist
📦 Deployment Notes
Prerequisites
MaxRetriesconfiguredConfiguration Steps
appsettings.jsonhasRetrysectionRollback Plan
If issues occur:
🔍 Additional Notes
Design Decisions
Performance Impact
Future Enhancements
See
docs/RETRY-LOGIC.mdfor planned improvements:Reviewer Notes:
This PR implements the complete retry logic as specified in issue #102. All acceptance criteria have been met:
✅ RetryConfiguration with exponential backoff
✅ Jitter to prevent thundering herd
✅ Error classification (retryable vs non-retryable)
✅ Integration with ProcessService retry handling
✅ Delayed message publishing via RabbitMQ
✅ Comprehensive unit tests
✅ Complete documentation
✅ Configuration in appsettings.json
Please review the implementation, tests, and documentation. Special attention to: