refactor: Replace in-process Inventory calls with HTTP client to inventory microservice#248
Open
devin-ai-integration[bot] wants to merge 1 commit intodevin/1773358765-initial-monolithfrom
Conversation
…entory microservice - Replace InventoryService with InventoryHttpClient that calls the new inventory-service API - Update InventoryController to proxy requests through InventoryHttpClient - Update OrderService to deduct stock via HTTP call instead of direct DB access - Remove InventoryItems DbSet from AppDbContext (inventory data now in microservice) - Remove inventory seed data from monolith (managed by microservice) - Remove Product.Inventory navigation property - Convert InventoryItem model to DTO for HTTP response deserialization - Add InventoryService:BaseUrl configuration in appsettings.json - Update tests with Moq-based HTTP client mocking - All 3 tests pass
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
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.
Summary
Decomposes the Inventory module out of the monolith by replacing all direct database access (
InventoryService+AppDbContext.InventoryItems) with an HTTP client (InventoryHttpClient) that calls the new standalone inventory microservice.What changed:
InventoryService.cs(direct DB access) → AddedInventoryHttpClient.cs(HTTP calls to inventory-service API)InventoryItemsDbSet and entity configuration fromAppDbContextSeedData.cs(now owned by the microservice)Product.Inventorynavigation property;InventoryItemmodel retained as a DTOOrderService.CreateOrderAsyncto callInventoryHttpClient.DeductStockAsyncinstead of deducting directly from DBProductServiceto remove.Include(p => p.Inventory)from all queriesInventoryHttpClientviaAddHttpClient<>inProgram.cswith configurableInventoryService:BaseUrlReview & Testing Checklist for Human
CreateOrderAsyncloops over items callingDeductStockAsyncfor each. If the 2nd deduction fails after the 1st succeeded, the 1st deduction is NOT rolled back on the microservice. Verify this is acceptable or add a saga/compensation pattern.InventoryHttpClienthas no Polly/resilience pipeline. A transient network failure will immediately fail order creation. Consider whetherAddStandardResilienceHandler()or similar should be added.new { quantity }(camelCase) and readsErrorResponse(string Error)(PascalCase). Verify the inventory microservice's serialization settings match — mismatches will silently produce null/default values.InventoryItemstable is removed from the DbContext but no migration drops it. Confirm this is intentional (table stays until microservice is validated) or add a migration.Notes
InventoryService:BaseUrldefaults tohttp://localhost:5001if not configured. In deployed environments, this must be set to the inventory-service's internal cluster URL.OrderServicebehavior via mocked HTTP. There are no integration tests forInventoryHttpClientitself (error handling, deserialization edge cases).Link to Devin session: https://partner-workshops.devinenterprise.com/sessions/b0cdc21a117f46a58c919164e6dd4259