Extract Catalog stock validation service#11
Open
mattfromcursor wants to merge 1 commit into
Open
Conversation
Co-authored-by: mattfromcursor <mattfromcursor@users.noreply.github.com>
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.
Plan
Summary
Extract Catalog stock validation from
OrderStatusChangedToAwaitingValidationIntegrationEventHandlerinto a dedicatedICatalogStockValidationServiceimplementation while leaving event contracts, RabbitMQ subscriptions, andICatalogIntegrationEventServiceoutbox/publish behavior unchanged.Files
src/Catalog.API/IntegrationEvents/ICatalogStockValidationService.cs- new interface for stock validation.src/Catalog.API/IntegrationEvents/CatalogStockValidationService.cs- new implementation that loads catalog items and returns eitherOrderStockRejectedIntegrationEventorOrderStockConfirmedIntegrationEvent.src/Catalog.API/IntegrationEvents/EventHandling/OrderStatusChangedToAwaitingValidationIntegrationEventHandler.cs- delegate validation to the service, then save and publish throughICatalogIntegrationEventServiceexactly as before.src/Catalog.API/Extensions/Extensions.cs- registerICatalogStockValidationServicewith DI.Interface methods
Task<IntegrationEvent> ValidateStockAsync(int orderId, IEnumerable<OrderStockItem> orderStockItems)DI
builder.Services.AddTransient<ICatalogStockValidationService, CatalogStockValidationService>();insrc/Catalog.API/Extensions/Extensions.csalongside the Catalog integration-event services.Risks to event publishing
SaveEventAndCatalogContextChangesAsync(...)followed byPublishThroughEventBusAsync(...)in the handler to avoid changing outbox persistence and publish ordering.ICatalogIntegrationEventService, EventBus contracts, event records, orOrdering.APIconsumers.OrderStatusChangedToAwaitingValidationIntegrationEventcontinues to reach the same handler.Build output
Requested command
dotnet restore eShop.Web.slnf && dotnet build eShop.Web.slnfResult: blocked by environment/network access before compilation. NuGet vulnerability audit could not reach
https://api.nuget.org/v3/index.json, producingNU1900warnings as errors across solution projects.Representative output:
/workspace/src/Catalog.API/Catalog.API.csproj : error NU1900: Warning As Error: Error occurred while getting package vulnerability data: Unable to load the service index for source https://api.nuget.org/v3/index.json.Failed to restore ...Compile verification fallback
dotnet restore eShop.Web.slnf -p:NuGetAudit=false && dotnet build eShop.Web.slnf --no-restore -p:NuGetAudit=false -p:LibraryRestore=FalseResult: build succeeded after disabling external NuGet audit and LibMan cdnjs restore for this network-restricted environment.
Output:
Catalog.API -> /workspace/artifacts/bin/Catalog.API/debug/Catalog.API.dlleShop.AppHost -> /workspace/artifacts/bin/eShop.AppHost/debug/eShop.AppHost.dllBuild succeeded.0 Warning(s)0 Error(s)