This repository has been archived by the owner on Apr 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
97 changed files
with
990 additions
and
273 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,24 @@ | ||
# Basic | ||
|
||
There is a single interface to use, **IDispatcher** in Kledex namespace. | ||
Note that all handlers are available as asynchronous as well as synchronous. | ||
The **IDispatcher** interface contains all the methods needed to send commands, publish events and get results from queries. | ||
|
||
The **IRepository<T>** interface can be used to load an aggregate from history by replaying all the associated events. | ||
|
||
Note that all methods and handlers are available as asynchronous as well as synchronous. | ||
|
||
There are 3 kinds of messages: | ||
- [Commands](https://github.com/lucabriguglia/Kledex/wiki/Commands) (single handler) | ||
- [Events](https://github.com/lucabriguglia/Kledex/wiki/Events) (multiple handlers) | ||
- [Queries](https://github.com/lucabriguglia/Kledex/wiki/Queries) (single handler) | ||
|
||
Mapping between dispatcher methods and message handlers: | ||
Mapping between dispatcher methods and handlers: | ||
|
||
| Method | Handler | | ||
| --- | --- | | ||
| SendAsync | ICommandHandlerAsync | | ||
| PublishAsync | IEventHandlerAsync | | ||
| GetResultAsync | IQueryHandlerAsync | | ||
|
||
It's also possible to use the following interfaces directly without going through the framework flows: | ||
- ICacheManager | ||
- IValidationService |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace Kledex.Sample.EventSourcing.Reporting | ||
{ | ||
public static class CacheKeys | ||
{ | ||
public static string ProductsCacheKey = "Kledex | Products"; | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
samples/Kledex.Sample.EventSourcing/Reporting/EventHandlers/EventHandlersForCaching.cs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using System.Threading.Tasks; | ||
using Kledex.Caching; | ||
using Kledex.Events; | ||
using Kledex.Sample.EventSourcing.Domain.Events; | ||
|
||
namespace Kledex.Sample.EventSourcing.Reporting.EventHandlers | ||
{ | ||
public class EventHandlersForCaching : | ||
IEventHandlerAsync<ProductCreated>, | ||
IEventHandlerAsync<ProductDeleted>, | ||
IEventHandlerAsync<ProductPublished>, | ||
IEventHandlerAsync<ProductUpdated>, | ||
IEventHandlerAsync<ProductWithdrew> | ||
{ | ||
private readonly ICacheManager _cacheManager; | ||
|
||
public EventHandlersForCaching(ICacheManager cacheManager) | ||
{ | ||
_cacheManager = cacheManager; | ||
} | ||
|
||
public Task HandleAsync(ProductCreated @event) | ||
{ | ||
return RemoveCacheAsync(); | ||
} | ||
|
||
public Task HandleAsync(ProductDeleted @event) | ||
{ | ||
return RemoveCacheAsync(); | ||
} | ||
|
||
public Task HandleAsync(ProductPublished @event) | ||
{ | ||
return RemoveCacheAsync(); | ||
} | ||
|
||
public Task HandleAsync(ProductUpdated @event) | ||
{ | ||
return RemoveCacheAsync(); | ||
} | ||
|
||
public Task HandleAsync(ProductWithdrew @event) | ||
{ | ||
return RemoveCacheAsync(); | ||
} | ||
|
||
private Task RemoveCacheAsync() | ||
{ | ||
return _cacheManager.RemoveAsync(CacheKeys.ProductsCacheKey); | ||
} | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.