feat: Implement ShippingProcessHandler Example (Phase 7.2)#149
Merged
feat: Implement ShippingProcessHandler Example (Phase 7.2)#149
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
Summary
This PR implements
ShippingProcessHandleras an example handler demonstrating shipping and logistics operations. The handler complementsOrderProcessHandlerby showcasing a different process type with distinct business logic focused on carrier management, shipping cost calculation, and warehouse coordination.Motivation and Context
This implementation provides a second concrete example of the process handler pattern, demonstrating how different business domains (shipping vs order processing) can be implemented using the same
IProcessHandlerinterface. It shows alternative patterns for validation (whitelist approach), return values (tracking numbers), and external service integration (carrier APIs).Link to related issue(s): Fixes #106
Type of Change
Changes Made
Key Changes
ProcessHandlerServiceCollectionExtensionsTechnical Details
Architecture changes:
IProcessHandlerinterfaceOrderProcessHandlerHandler Implementation:
TRK{timestamp}{shipmentId}Validation Strategy:
Error Handling:
InvalidOperationExceptionfor validation failures (non-retryable)HttpRequestExceptionfor capacity issues (retryable)OperationCanceledExceptionfor cancellation supportReturn Values:
OrderProcessHandler(void return)Testing
Test Coverage
Test Suite Details
ShippingProcessHandlerTests (11 tests):
ProcessType_Should_ReturnShipping- Validates process typeExecuteAsync_Should_ThrowInvalidOperationException_WhenShipmentIdMissing- Required field validationExecuteAsync_Should_ThrowInvalidOperationException_WhenOrderIdMissing- Required field validationExecuteAsync_Should_ThrowInvalidOperationException_WhenDestinationMissing- Required field validationExecuteAsync_Should_ThrowInvalidOperationException_WhenCarrierMissing- Required field validationExecuteAsync_Should_ThrowInvalidOperationException_WhenCarrierInvalid- Whitelist validationExecuteAsync_Should_AcceptValidCarriers- Theory test (4 data points: UPS, FEDEX, DHL, USPS)ExecuteAsync_Should_AcceptCarriersInLowercase- Theory test (4 data points: case-insensitive)ExecuteAsync_Should_ThrowOperationCanceledException_WhenCancellationRequested- Cancellation supportExecuteAsync_Should_CompleteSuccessfully_WithValidData- Happy pathConstructor_Should_ThrowArgumentNullException_WhenLoggerIsNull- Null guardManual Testing
Testing instructions provided in
docs/examples/shipping-process-examples.md:dotnet test --filter "FullyQualifiedName~ShippingProcessHandler"Test Evidence
Checklist
Before requesting review, confirm:
Asyncsuffixdotnet formatImplementation Details
Files Created/Modified
Created:
src/StarGate.Server/Handlers/ShippingProcessHandler.cs(8.4 KB)IProcessHandlerwith ProcessType = "shipping"tests/StarGate.Server.Tests/Handlers/ShippingProcessHandlerTests.cs(8.3 KB)docs/examples/shipping-process-examples.md(13.6 KB)Modified:
4.
src/StarGate.Server/Extensions/ProcessHandlerServiceCollectionExtensions.csCommits
feat: implement ShippingProcessHandler for shipping operationstest: add comprehensive unit tests for ShippingProcessHandlerdocs: add shipping process API examples and documentationfeat: register ShippingProcessHandler in DI containerComparison with OrderProcessHandler
This handler demonstrates alternative implementation patterns:
Additional Notes
Simulated Failures:
HttpRequestExceptionExtension Points:
Production Considerations (documented):
Review Focus Areas
OrderProcessHandlerpattern andIProcessHandlerinterface usageRelated Issues:
Documentation References: