Skip to content

Commit 2b29d16

Browse files
author
Anthony Sneed
committed
Revert "Jsmith/commands (#1)"
This reverts commit f12accf.
1 parent 362a267 commit 2b29d16

File tree

111 files changed

+1161
-2955
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+1161
-2955
lines changed

EventDriven.CQRS.sln

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,31 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{AF357BE9-9A6
1212
EndProject
1313
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EventDriven.CQRS.Abstractions", "src\EventDriven.CQRS.Abstractions\EventDriven.CQRS.Abstractions.csproj", "{1F665C29-BF1C-45BA-8CB9-829E85C34999}"
1414
EndProject
15+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{269CD137-4093-4100-B33E-808586D335F6}"
16+
EndProject
1517
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "reference-architecture", "reference-architecture", "{C4FD0AF1-927A-4860-A634-7CE342807692}"
1618
EndProject
19+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EventDriven.CQRS.Tests", "test\EventDriven.CQRS.Tests\EventDriven.CQRS.Tests.csproj", "{9809006C-2F6B-44A1-8AE2-BC449368D209}"
20+
EndProject
1721
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CustomerService", "reference-architecture\CustomerService\CustomerService.csproj", "{48983715-E6DF-462F-AF3C-769C1122794F}"
1822
EndProject
1923
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OrderService", "reference-architecture\OrderService\OrderService.csproj", "{16A5B2CB-8C46-4F3E-B7A1-97C47D9F66E7}"
2024
EndProject
2125
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "json", "json", "{B11B21E0-7B89-4285-990A-D98793310B02}"
22-
ProjectSection(SolutionItems) = preProject
23-
reference-architecture\json\customers.json = reference-architecture\json\customers.json
24-
reference-architecture\json\orders.json = reference-architecture\json\orders.json
25-
EndProjectSection
26+
ProjectSection(SolutionItems) = preProject
27+
reference-architecture\json\customers.json = reference-architecture\json\customers.json
28+
reference-architecture\json\orders.json = reference-architecture\json\orders.json
29+
EndProjectSection
2630
EndProject
2731
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common", "reference-architecture\Common\Common.csproj", "{FC04D111-903D-49FF-84A6-8806C71E2168}"
2832
EndProject
2933
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dapr", "dapr", "{F0E48E00-7D72-4614-9C13-90A7B015B06F}"
3034
EndProject
3135
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "components", "components", "{00BA9501-787E-465C-97D0-F51295D97802}"
32-
ProjectSection(SolutionItems) = preProject
33-
reference-architecture\dapr\components\pubsub.yaml = reference-architecture\dapr\components\pubsub.yaml
34-
reference-architecture\dapr\components\snssqs-pubsub.yaml = reference-architecture\dapr\components\snssqs-pubsub.yaml
35-
EndProjectSection
36-
EndProject
37-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CustomerService.Tests", "reference-architecture\CustomerService.Tests\CustomerService.Tests.csproj", "{A2B684E5-7DB5-4815-80E9-16F0EFBE15D8}"
38-
EndProject
39-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OrderService.Tests", "reference-architecture\OrderService.Tests\OrderService.Tests.csproj", "{A7D3F069-598D-435D-8B33-522767AACB76}"
36+
ProjectSection(SolutionItems) = preProject
37+
reference-architecture\dapr\components\pubsub.yaml = reference-architecture\dapr\components\pubsub.yaml
38+
reference-architecture\dapr\components\snssqs-pubsub.yaml = reference-architecture\dapr\components\snssqs-pubsub.yaml
39+
EndProjectSection
4040
EndProject
4141
Global
4242
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -48,6 +48,10 @@ Global
4848
{1F665C29-BF1C-45BA-8CB9-829E85C34999}.Debug|Any CPU.Build.0 = Debug|Any CPU
4949
{1F665C29-BF1C-45BA-8CB9-829E85C34999}.Release|Any CPU.ActiveCfg = Release|Any CPU
5050
{1F665C29-BF1C-45BA-8CB9-829E85C34999}.Release|Any CPU.Build.0 = Release|Any CPU
51+
{9809006C-2F6B-44A1-8AE2-BC449368D209}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
52+
{9809006C-2F6B-44A1-8AE2-BC449368D209}.Debug|Any CPU.Build.0 = Debug|Any CPU
53+
{9809006C-2F6B-44A1-8AE2-BC449368D209}.Release|Any CPU.ActiveCfg = Release|Any CPU
54+
{9809006C-2F6B-44A1-8AE2-BC449368D209}.Release|Any CPU.Build.0 = Release|Any CPU
5155
{48983715-E6DF-462F-AF3C-769C1122794F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
5256
{48983715-E6DF-462F-AF3C-769C1122794F}.Debug|Any CPU.Build.0 = Debug|Any CPU
5357
{48983715-E6DF-462F-AF3C-769C1122794F}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -60,28 +64,19 @@ Global
6064
{FC04D111-903D-49FF-84A6-8806C71E2168}.Debug|Any CPU.Build.0 = Debug|Any CPU
6165
{FC04D111-903D-49FF-84A6-8806C71E2168}.Release|Any CPU.ActiveCfg = Release|Any CPU
6266
{FC04D111-903D-49FF-84A6-8806C71E2168}.Release|Any CPU.Build.0 = Release|Any CPU
63-
{A2B684E5-7DB5-4815-80E9-16F0EFBE15D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
64-
{A2B684E5-7DB5-4815-80E9-16F0EFBE15D8}.Debug|Any CPU.Build.0 = Debug|Any CPU
65-
{A2B684E5-7DB5-4815-80E9-16F0EFBE15D8}.Release|Any CPU.ActiveCfg = Release|Any CPU
66-
{A2B684E5-7DB5-4815-80E9-16F0EFBE15D8}.Release|Any CPU.Build.0 = Release|Any CPU
67-
{A7D3F069-598D-435D-8B33-522767AACB76}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
68-
{A7D3F069-598D-435D-8B33-522767AACB76}.Debug|Any CPU.Build.0 = Debug|Any CPU
69-
{A7D3F069-598D-435D-8B33-522767AACB76}.Release|Any CPU.ActiveCfg = Release|Any CPU
70-
{A7D3F069-598D-435D-8B33-522767AACB76}.Release|Any CPU.Build.0 = Release|Any CPU
7167
EndGlobalSection
7268
GlobalSection(SolutionProperties) = preSolution
7369
HideSolutionNode = FALSE
7470
EndGlobalSection
7571
GlobalSection(NestedProjects) = preSolution
7672
{1F665C29-BF1C-45BA-8CB9-829E85C34999} = {AF357BE9-9A6E-48A3-A995-E75F2147A43F}
73+
{9809006C-2F6B-44A1-8AE2-BC449368D209} = {269CD137-4093-4100-B33E-808586D335F6}
7774
{48983715-E6DF-462F-AF3C-769C1122794F} = {C4FD0AF1-927A-4860-A634-7CE342807692}
7875
{16A5B2CB-8C46-4F3E-B7A1-97C47D9F66E7} = {C4FD0AF1-927A-4860-A634-7CE342807692}
7976
{B11B21E0-7B89-4285-990A-D98793310B02} = {C4FD0AF1-927A-4860-A634-7CE342807692}
8077
{FC04D111-903D-49FF-84A6-8806C71E2168} = {C4FD0AF1-927A-4860-A634-7CE342807692}
8178
{F0E48E00-7D72-4614-9C13-90A7B015B06F} = {AFFCBFA4-9D64-43AA-AC59-D4CC54BD9C72}
8279
{00BA9501-787E-465C-97D0-F51295D97802} = {F0E48E00-7D72-4614-9C13-90A7B015B06F}
83-
{A2B684E5-7DB5-4815-80E9-16F0EFBE15D8} = {C4FD0AF1-927A-4860-A634-7CE342807692}
84-
{A7D3F069-598D-435D-8B33-522767AACB76} = {C4FD0AF1-927A-4860-A634-7CE342807692}
8580
EndGlobalSection
8681
GlobalSection(ExtensibilityGlobals) = postSolution
8782
SolutionGuid = {427A0D03-63CA-48AE-AA95-D21800101398}

ReadMe.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ The **EventDriven.CQRS.Abstractions** library contains interfaces and abstract b
2828
The **Reference Architecture** projects demonstrate how to apply these concepts to two microservices: `CustomerService` and `OrderService`. In addition, each service has *separate controllers for read and write operations*, thus segregating command and query responsibilities, with different sets of models, or Data Transfer Objects (DTO's).
2929
- **Query Controller**: Uses repository to retrieve entities and converts them to DTO's with AutoMapper.
3030
- **Command Controller**: Converts DTO's to domain entities using AutoMapper. Then hands control over to a command handler for executing business logic.
31-
- **Command Broker**: Dispatches the command object to the correct command handler.
3231
- **Command Handler**: Uses a domain entity to process commands which generate one or more domain events, then requests entity to apply the domain events in order to mutate entity state. Persists entity state to a state store and optionally publishes an integration event which is handled by another microservice.
3332
- **Repository**: Persists entity state to a database.
3433
- **Event Bus**: Used to publish integration events, as well as subscribe to events using an event handler. Dapr is used to abstract away the underlying pub/sub implementation. The default is Redis (for local development), but Dapr can be configured to use other components, such as AWS SNS+SQS.
@@ -88,9 +87,9 @@ The **Reference Architecture** projects demonstrate how to apply these concepts
8887
8988
1. Add **Domain** and **CustomerAggregate** folders to the project, then add a `Customer` class that extends `Entity`.
9089
- Add properties representing entity state.
91-
- Create commands that are C# records and extend an `ICommand` interface with the result type as the generic.
90+
- Create commands that are C# records and extend a `Command` base class.
9291
```csharp
93-
public record CreateCustomer(Customer Customer) : ICommand<CommandResult<Customer>>;
92+
public record CreateCustomer(Customer Customer) : Command.Create(Customer.Id);
9493
```
9594
- Create domain events that extend `DomainEvent`.
9695
```csharp
@@ -113,7 +112,7 @@ The **Reference Architecture** projects demonstrate how to apply these concepts
113112
- Inject `ICustomerRepository`, `IEventBus` and `IMapper` into the ctor.
114113
- In the handler for `CreateCustomer`, write code to process the command, apply events, and persist the entity.
115114
```csharp
116-
public async Task<CommandResult<Customer>> Handle(CreateCustomer request, CancellationToken cancellationToken)
115+
public async Task<CommandResult<Customer>> Handle(CreateCustomer command)
117116
{
118117
// Process command
119118
_logger.LogInformation("Handling command: {commandName}", nameof(CreateCustomer));
@@ -138,7 +137,7 @@ The **Reference Architecture** projects demonstrate how to apply these concepts
138137
```
139138
- In the `UpdateCustomer` handler, see if the shipping address has changed, and if so, publish a `CustomerAddressUpdated` integration event, so that the order service can update the shipping address in the customer's orders.
140139
```csharp
141-
public async Task<CommandResult<Customer>> Handle(UpdateCustomer request, CancellationToken cancellationToken)
140+
public async Task<CommandResult<Customer>> Handle(UpdateCustomer command)
142141
{
143142
// Compare shipping addresses
144143
_logger.LogInformation("Handling command: {commandName}", nameof(UpdateCustomer));
@@ -168,7 +167,7 @@ The **Reference Architecture** projects demonstrate how to apply these concepts
168167
}
169168
}
170169
```
171-
3. Add a `CustomerCommandController` to the project that injects `ICommandBroker` into the ctor.
170+
3. Add a `CustomerCommandController` to the project that injects `CustomerCommandHandler` into the ctor.
172171
- Add Post, Put and Delete actions which accept a `Customer` DTO, map it to a `Customer` entity and invoke the appropriate command handler.
173172
4. Add a `CustomerQueryController` to the project that injects a `ICustomerRepository` into the ctor.
174173
- Use the repository to retrieve entities, then map those to `Customer` DTO objects.

global.json

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
using System;
2-
using System.Diagnostics.CodeAnalysis;
32
using Common.Integration.Models;
43
using EventDriven.EventBus.Abstractions;
54

65
namespace Common.Integration.Events
76
{
8-
[ExcludeFromCodeCoverage]
97
public record CustomerAddressUpdated(Guid CustomerId, Address ShippingAddress) : IntegrationEvent;
108
}
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
using System.Diagnostics.CodeAnalysis;
2-
31
namespace Common.Integration.Models
42
{
5-
[ExcludeFromCodeCoverage]
63
public record Address(string Street, string City, string State, string Country, string PostalCode);
74
}

reference-architecture/CustomerService.Tests/Controllers/CustomerCommandControllerTests.cs

Lines changed: 0 additions & 135 deletions
This file was deleted.

0 commit comments

Comments
 (0)