Skip to content

Commit 640e192

Browse files
author
Anthony Sneed
committed
Add xml docs, set package info.
1 parent f426f3a commit 640e192

File tree

21 files changed

+176
-43
lines changed

21 files changed

+176
-43
lines changed

reference-architecture/Common/Common.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</PropertyGroup>
66

77
<ItemGroup>
8-
<PackageReference Include="EventDriven.EventBus.Abstractions" Version="1.0.0-rc1" />
8+
<PackageReference Include="EventDriven.EventBus.Abstractions" Version="1.0.0" />
99
</ItemGroup>
1010

1111
</Project>

reference-architecture/CustomerService/CustomerService.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<ItemGroup>
88
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="8.1.1" />
9-
<PackageReference Include="EventDriven.EventBus.Dapr" Version="1.0.0-rc1" />
9+
<PackageReference Include="EventDriven.EventBus.Dapr" Version="1.0.0" />
1010
<PackageReference Include="MongoDB.Driver" Version="2.12.2" />
1111
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.1.3" />
1212
<PackageReference Include="URF.Core.Mongo" Version="3.1.3" />

reference-architecture/CustomerService/Domain/CustomerAggregate/CommandHandlers/CustomerCommandHandler.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public CustomerCommandHandler(
3737
public async Task<CommandResult<Customer>> Handle(CreateCustomer command)
3838
{
3939
// Process command
40-
_logger.LogInformation("Handling command: {commandName}", nameof(CreateCustomer));
40+
_logger.LogInformation("Handling command: {CommandName}", nameof(CreateCustomer));
4141
var events = command.Customer.Process(command);
4242

4343
// Apply events
@@ -54,7 +54,7 @@ public async Task<CommandResult<Customer>> Handle(CreateCustomer command)
5454
public async Task<CommandResult<Customer>> Handle(UpdateCustomer command)
5555
{
5656
// Compare shipping addresses
57-
_logger.LogInformation("Handling command: {commandName}", nameof(UpdateCustomer));
57+
_logger.LogInformation("Handling command: {CommandName}", nameof(UpdateCustomer));
5858
var existing = await _repository.Get(command.EntityId);
5959
var addressChanged = command.Customer.ShippingAddress != existing.ShippingAddress;
6060

@@ -68,7 +68,7 @@ public async Task<CommandResult<Customer>> Handle(UpdateCustomer command)
6868
if (addressChanged)
6969
{
7070
var shippingAddress = _mapper.Map<Integration.Models.Address>(entity.ShippingAddress);
71-
_logger.LogInformation("Publishing event: {eventName}", $"v1.{nameof(CustomerAddressUpdated)}");
71+
_logger.LogInformation("Publishing event: {EventName}", $"v1.{nameof(CustomerAddressUpdated)}");
7272
await _eventBus.PublishAsync(
7373
new CustomerAddressUpdated(entity.Id, shippingAddress),
7474
null, "v1");
@@ -84,7 +84,7 @@ await _eventBus.PublishAsync(
8484
public async Task<CommandResult<Customer>> Handle(RemoveCustomer command)
8585
{
8686
// Persist entity
87-
_logger.LogInformation("Handling command: {commandName}", nameof(RemoveCustomer));
87+
_logger.LogInformation("Handling command: {CommandName}", nameof(RemoveCustomer));
8888
await _repository.Remove(command.EntityId);
8989
return new CommandResult<Customer>(CommandOutcome.Accepted);
9090
}

reference-architecture/OrderService/Domain/OrderAggregate/CommandHandlers/OrderCommandHandler.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public OrderCommandHandler(
2929
public async Task<CommandResult<Order>> Handle(CreateOrder command)
3030
{
3131
// Process command
32-
_logger.LogInformation("Handling command: {commandName}", nameof(CreateOrder));
32+
_logger.LogInformation("Handling command: {CommandName}", nameof(CreateOrder));
3333
var events = command.Order.Process(command);
3434

3535
// Apply events
@@ -45,7 +45,7 @@ public async Task<CommandResult<Order>> Handle(CreateOrder command)
4545

4646
public async Task<CommandResult<Order>> Handle(UpdateOrder command)
4747
{
48-
_logger.LogInformation("Handling command: {commandName}", nameof(UpdateOrder));
48+
_logger.LogInformation("Handling command: {CommandName}", nameof(UpdateOrder));
4949

5050
try
5151
{
@@ -63,15 +63,15 @@ public async Task<CommandResult<Order>> Handle(UpdateOrder command)
6363
public async Task<CommandResult<Order>> Handle(RemoveOrder command)
6464
{
6565
// Persist entity
66-
_logger.LogInformation("Handling command: {commandName}", nameof(RemoveOrder));
66+
_logger.LogInformation("Handling command: {CommandName}", nameof(RemoveOrder));
6767
await _repository.RemoveOrder(command.EntityId);
6868
return new CommandResult<Order>(CommandOutcome.Accepted);
6969
}
7070

7171
public async Task<CommandResult<Order>> Handle(ShipOrder command)
7272
{
7373
// Process command
74-
_logger.LogInformation("Handling command: {commandName}", nameof(ShipOrder));
74+
_logger.LogInformation("Handling command: {CommandName}", nameof(ShipOrder));
7575
var entity = await _repository.GetOrder(command.EntityId);
7676
if (entity == null) return new CommandResult<Order>(CommandOutcome.NotFound);
7777
var events = entity.Process(command);
@@ -97,7 +97,7 @@ public async Task<CommandResult<Order>> Handle(ShipOrder command)
9797
public async Task<CommandResult<Order>> Handle(CancelOrder command)
9898
{
9999
// Process command
100-
_logger.LogInformation("Handling command: {commandName}", nameof(CancelOrder));
100+
_logger.LogInformation("Handling command: {CommandName}", nameof(CancelOrder));
101101
var entity = await _repository.GetOrder(command.EntityId);
102102
if (entity == null) return new CommandResult<Order>(CommandOutcome.NotFound);
103103
var events = entity.Process(command);

reference-architecture/OrderService/Integration/EventHandlers/CustomerAddressUpdatedEventHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public CustomerAddressUpdatedEventHandler(IOrderRepository orderRepository,
2525

2626
public override async Task HandleAsync(CustomerAddressUpdated @event)
2727
{
28-
_logger.LogInformation("Handling CustomerAddressUpdated event.");
28+
_logger.LogInformation("Handling CustomerAddressUpdated event");
2929
var orders = await _orderRepository.GetCustomerOrders(@event.CustomerId);
3030
foreach (var order in orders)
3131
{

reference-architecture/OrderService/OrderService.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<ItemGroup>
88
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="8.1.1" />
9-
<PackageReference Include="EventDriven.EventBus.Dapr" Version="1.0.0-rc1" />
9+
<PackageReference Include="EventDriven.EventBus.Dapr" Version="1.0.0" />
1010
<PackageReference Include="MongoDB.Driver" Version="2.12.2" />
1111
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.1.3" />
1212
<PackageReference Include="URF.Core.Mongo" Version="3.1.3" />

src/EventDriven.CQRS.Abstractions/Commands/Command.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,63 @@
22

33
namespace EventDriven.CQRS.Abstractions.Commands
44
{
5+
/// <summary>
6+
/// Represents a command.
7+
/// </summary>
58
public record Command : ICommand
69
{
10+
/// <inheritdoc />
711
public Guid EntityId => default(Guid);
12+
13+
/// <inheritdoc />
814
public string EntityEtag { get; set; }
15+
16+
/// <inheritdoc />
917
public bool? EntityExists => false;
1018

19+
/// <summary>
20+
/// Represents a Create command.
21+
/// </summary>
22+
/// <param name="EntityId">Represents the ID of the entity the command is in reference to.</param>
1123
public abstract record Create(
1224
Guid EntityId = default) : ICommand
1325
{
26+
/// <inheritdoc />
1427
public string EntityEtag { get; set; }
28+
29+
/// <inheritdoc />
1530
public bool? EntityExists => false;
1631
}
1732

33+
/// <summary>
34+
/// Represents an Update command.
35+
/// </summary>
36+
/// <param name="EntityId">Represents the ID of the entity the command is in reference to.</param>
37+
/// <param name="EntityEtag">If provided, refers to the version of the entity to update.</param>
1838
public abstract record Update(
1939
Guid EntityId,
2040
string EntityEtag = null) : ICommand
2141
{
42+
/// <inheritdoc />
2243
public string EntityEtag { get; set; } = EntityEtag;
44+
45+
/// <inheritdoc />
2346
public bool? EntityExists => true;
2447
}
2548

49+
/// <summary>
50+
/// Represents a Remove command.
51+
/// </summary>
52+
/// <param name="EntityId">Represents the ID of the entity the command is in reference to.</param>
53+
/// <param name="EntityEtag">If provided, refers to the version of the entity to update.</param>
2654
public abstract record Remove(
2755
Guid EntityId,
2856
string EntityEtag = null) : ICommand
2957
{
58+
/// <inheritdoc />
3059
public string EntityEtag { get; set; } = EntityEtag;
60+
61+
/// <inheritdoc />
3162
public bool? EntityExists => true;
3263
}
3364
}
Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,38 @@
11
namespace EventDriven.CQRS.Abstractions.Commands
22
{
3+
/// <summary>
4+
/// Outcome of a command.
5+
/// </summary>
36
public enum CommandOutcome
47
{
5-
/// only if the command was accepted
8+
/// <summary>
9+
/// Only if the command was accepted
10+
/// </summary>
611
Accepted,
7-
/// if the command was rejected due to a conflict
12+
13+
/// <summary>
14+
/// If the command was rejected due to a conflict.
15+
/// </summary>
816
Conflict,
9-
/// if the command was invalid due to its parameters
17+
18+
/// <summary>
19+
/// If the command was invalid due to its parameters.
20+
/// </summary>
1021
InvalidCommand,
11-
///If the command was invalid due to the object state
22+
23+
/// <summary>
24+
/// If the command was invalid due to the object state.
25+
/// </summary>
1226
InvalidState,
13-
// Not handled
27+
28+
/// <summary>
29+
/// Not handled.
30+
/// </summary>
1431
NotHandled,
15-
//Entity was not found
32+
33+
/// <summary>
34+
/// Entity was not found.
35+
/// </summary>
1636
NotFound
1737
}
1838
}

src/EventDriven.CQRS.Abstractions/Commands/CommandResult.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,37 @@
55
namespace EventDriven.CQRS.Abstractions.Commands
66
{
77
/// <summary>
8-
/// Represents the result of dispatching a command
8+
/// Represents the result of dispatching a command.
99
/// </summary>
1010
public record CommandResult(
1111
CommandOutcome Outcome,
1212
IDictionary<string, string[]> Errors = null);
1313

1414
/// <summary>
15-
/// Represents the result of dispatching a command
15+
/// Represents the result of dispatching a command.
1616
/// </summary>
1717
public record CommandResult<TEntity> : CommandResult
1818
where TEntity : Entity
1919
{
20-
public List<TEntity> Entities { get; } = new List<TEntity>();
20+
/// <summary>
21+
/// Entities associated with the result.
22+
/// </summary>
23+
public List<TEntity> Entities { get; } = new();
2124

25+
/// <summary>
26+
/// Entity associated with the result.
27+
/// </summary>
2228
public TEntity Entity => Entities.FirstOrDefault();
2329

30+
/// <inheritdoc />
2431
public CommandResult(
2532
CommandOutcome outcome,
2633
params TEntity[] entities) : base(outcome)
2734
{
2835
foreach (var entity in entities) Entities.Add(entity);
2936
}
37+
38+
/// <inheritdoc />
3039
public CommandResult(
3140
CommandOutcome outcome,
3241
IDictionary<string, string[]> errors,

src/EventDriven.CQRS.Abstractions/Commands/ICommand.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace EventDriven.CQRS.Abstractions.Commands
44
{
55
/// <summary>
6-
/// Represents a command
6+
/// An object that is sent to the domain for a state change which is handled by a command handler.
77
/// </summary>
88
public interface ICommand
99
{
@@ -28,7 +28,6 @@ public interface ICommand
2828
/// <li>Otherwise, If the value is null, and the EntityEtag is null, no assertion for the entity existing or not will be made. </li>
2929
/// </ul>
3030
/// </summary>
31-
/// <value></value>
3231
bool? EntityExists { get; }
3332
}
3433
}

src/EventDriven.CQRS.Abstractions/Commands/ICommandProcessor.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
namespace EventDriven.CQRS.Abstractions.Commands
55
{
66
/// <summary>
7-
/// Command handler.
7+
/// Processes a command by generating one or more domain events.
88
/// </summary>
99
/// <typeparam name="TCommand">The type of command</typeparam>
1010
public interface ICommandProcessor<in TCommand> where TCommand : class, ICommand
1111
{
1212
/// <summary>
13-
/// Process specified command by creating a domain event.
13+
/// Process specified command by creating one or more domain events.
1414
/// </summary>
1515
/// <param name="command">The command to process.</param>
16-
/// <returns>Domain events to apply.</returns>
16+
/// <returns>Domain events resulting from the command.</returns>
1717
IEnumerable<IDomainEvent> Process(TCommand command);
1818
}
1919
}

src/EventDriven.CQRS.Abstractions/Entities/Entity.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,32 @@
22

33
namespace EventDriven.CQRS.Abstractions.Entities
44
{
5+
/// <inheritdoc />
56
public abstract class Entity : IEntity
67
{
8+
/// <inheritdoc />
79
public Guid Id { get; set; }
10+
11+
/// <inheritdoc />
812
public long SequenceNumber { get; set; }
13+
14+
/// <inheritdoc />
915
public string ETag { get; set; }
16+
17+
/// <inheritdoc />
1018
public EntityState State { get; set; } = EntityState.Active;
1119

20+
/// <summary>
21+
/// Set entity state to Deleted.
22+
/// </summary>
1223
protected void MarkDeleted()
1324
{
1425
State = EntityState.Deleted;
1526
}
1627

28+
/// <summary>
29+
/// Set entity state to Frozen.
30+
/// </summary>
1731
protected void Freeze()
1832
{
1933
State = EntityState.Frozen;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,23 @@
11
namespace EventDriven.CQRS.Abstractions.Entities
22
{
3+
/// <summary>
4+
/// The state of an entity.
5+
/// </summary>
36
public enum EntityState
47
{
8+
/// <summary>
9+
/// The entity is in an active state.
10+
/// </summary>
511
Active,
12+
13+
/// <summary>
14+
/// The entity is in a frozen state.
15+
/// </summary>
616
Frozen,
17+
18+
/// <summary>
19+
/// The entity is an a deleted state.
20+
/// </summary>
721
Deleted
822
}
923
}

src/EventDriven.CQRS.Abstractions/Entities/IEntity.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,25 @@
22

33
namespace EventDriven.CQRS.Abstractions.Entities
44
{
5+
/// <summary>
6+
/// A type that has an identity with behavior and state that can change over time.
7+
/// </summary>
58
public interface IEntity
69
{
710
/// <summary>
811
/// The ID of the Entity.
912
/// </summary>
10-
/// <value></value>
1113
Guid Id { get; set; }
1214

1315
/// <summary>
1416
/// The sequence number (equal to the highest event sequence number applied).
1517
/// </summary>
16-
/// <value></value>
1718
long SequenceNumber { get; set; }
1819

1920
/// <summary>
2021
/// Represents a unique ID that must change atomically with each store of the entity
2122
/// to its underlying storage medium.
2223
/// </summary>
23-
/// <value></value>
2424
string ETag { get; set; }
2525

2626
/// <summary>

0 commit comments

Comments
 (0)