Skip to content

Removal of PriceWatcherService #121

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Conversation

feO2x
Copy link
Contributor

@feO2x feO2x commented Mar 22, 2023

This PR contains the following changes:

  • the PriceDropController is now part of the ProductsService. I introduced a simple unit of work and async factory that encapsulate ADO.NET for SQL Server and In-Memory data. This allows access to the database in a completely asynchronous manner while keeping the business logic in the controller completely decoupled from any specific data access technology.
  • I found out that, when sending events, Dapr provides no guarantee that the event will actually reach the message broker (e.g. when the message broker is down). Dapr only ensures at-least-once semantics when messages are routed to the subscriber (see Outbox pattern for statestore + pubsub in Dapr dapr/dapr#4233). I therefore implemented the Transactional Outbox pattern when the price-drop event is published by the PriceDropController.
  • I moved the PriceWatcherController with its Register endpoint to the PriceDropNotifier service. It currently uses an in-memory data access layer with a simplified Unit-of-Work pattern to store registrations.
  • The PriceDropNotifierController now fetches all registrations and sends emails accordingly.
  • I removed the PriceWatcher service completely, updated the gateway routing config and removed all corresponding entries from IAC and the GitHub workflows.

Issues I still have:

  • I couldn't test the changes to GitHub workflows and IAC - maybe we should review them together? I don't think it's currently easy to setup a new environment where such infrastructure changes can be tested in isolation.

feO2x added 6 commits March 21, 2023 09:05
csproj now has consistent formatting.
The InMemoryProductsRepository is now registered as a singleton.
Removed unused using statements at the beginning of Program.cs

Signed-off-by: Kenny Pflug <kenny.pflug@thinktecture.com>
This commit is quite large and incorporates the following things:
- introduction of Unit-Of-Work pattern for ADO.NET for MS SQL Server and in-memory data
- clear separation of Business Logic and I/O
- IAsyncFactory that asynchronously opens the underlying SqlConnection and starts transaction if necessary
- the Transactional Outbox pattern to go from at-most-once to at-least-once when publishing messages to the broker

Signed-off-by: Kenny Pflug <kenny.pflug@thinktecture.com>
…iguration

Signed-off-by: Kenny Pflug <kenny.pflug@thinktecture.com>
Signed-off-by: Kenny Pflug <kenny.pflug@thinktecture.com>
Signed-off-by: Kenny Pflug <kenny.pflug@thinktecture.com>
@feO2x feO2x requested a review from ThorstenHans March 22, 2023 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant