-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #56 from atc-net/release/v1.14
Release of new minor version v1.14
- Loading branch information
Showing
48 changed files
with
814 additions
and
175 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,10 +28,10 @@ jobs: | |
- name: ⚙️ Setup GIT versioning | ||
uses: dotnet/[email protected] | ||
|
||
- name: ⚙️ Setup dotnet 7.0.x | ||
- name: ⚙️ Setup dotnet 9.0.x | ||
uses: actions/setup-dotnet@v1 | ||
with: | ||
dotnet-version: '7.0.x' | ||
dotnet-version: '9.0.x' | ||
|
||
- name: 🛠️ Building library in release mode | ||
run: dotnet pack -c Release -o ${GITHUB_WORKSPACE}/packages -p:ContinuousIntegrationBuild=true -p:publicrelease=true | ||
|
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 |
---|---|---|
|
@@ -59,10 +59,10 @@ jobs: | |
with: | ||
setAllVars: true | ||
|
||
- name: ⚙️ Setup dotnet 7.0.x | ||
- name: ⚙️ Setup dotnet 9.0.x | ||
uses: actions/setup-dotnet@v1 | ||
with: | ||
dotnet-version: '7.0.x' | ||
dotnet-version: '9.0.x' | ||
|
||
- name: 🛠️ Update changelog | ||
uses: thomaseizinger/[email protected] | ||
|
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 was deleted.
Oops, something went wrong.
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,31 @@ | ||
using Atc.Cosmos.EventStore.Cqrs; | ||
|
||
namespace GettingStarted; | ||
|
||
public record CreateCommand(string Id, string Name, string Address) | ||
: CommandBase<SampleEventStreamId>(new SampleEventStreamId(Id)); | ||
|
||
public class CreateCommandHandler : | ||
ICommandHandler<CreateCommand>, | ||
IConsumeEvent<CreateCommand> | ||
{ | ||
private bool created; | ||
|
||
public void Consume(CreateCommand evt, EventMetadata metadata) | ||
{ | ||
this.created = true; | ||
} | ||
|
||
public ValueTask ExecuteAsync( | ||
CreateCommand command, | ||
ICommandContext context, | ||
CancellationToken cancellationToken) | ||
{ | ||
if (!created) | ||
{ | ||
context.AddEvent(new AddedEvent(command.Name, command.Address)); | ||
} | ||
|
||
return ValueTask.CompletedTask; | ||
} | ||
} |
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,44 @@ | ||
using Atc.Cosmos.EventStore.Cqrs; | ||
|
||
namespace GettingStarted; | ||
|
||
public record DeleteCommand(string Id, string Reason) | ||
: CommandBase<SampleEventStreamId>(new SampleEventStreamId(Id)); | ||
|
||
public class DeleteCommandHandler : | ||
ICommandHandler<DeleteCommand>, | ||
IConsumeEvent<AddedEvent>, | ||
IConsumeEvent<DeletedEvent> | ||
{ | ||
private bool created; | ||
private bool deleted; | ||
|
||
public void Consume(AddedEvent evt, EventMetadata metadata) | ||
{ | ||
this.created = true; | ||
} | ||
|
||
public void Consume(DeletedEvent evt, EventMetadata metadata) | ||
{ | ||
this.deleted = true; | ||
} | ||
|
||
public ValueTask ExecuteAsync( | ||
DeleteCommand command, | ||
ICommandContext context, | ||
CancellationToken cancellationToken) | ||
{ | ||
if (!created) | ||
{ | ||
throw new InvalidOperationException("Cannot delete non-existing entity."); | ||
} | ||
|
||
if (deleted) | ||
{ | ||
throw new InvalidOperationException("Already deleted."); | ||
} | ||
|
||
context.AddEvent(new DeletedEvent(command.Reason)); | ||
return ValueTask.CompletedTask; | ||
} | ||
} |
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,44 @@ | ||
using Atc.Cosmos.EventStore.Cqrs; | ||
|
||
namespace GettingStarted; | ||
|
||
public record UpdateNameCommand(string Id, string Name) | ||
: CommandBase<SampleEventStreamId>(new SampleEventStreamId(Id)); | ||
|
||
public class UpdateNameCommandHandler : | ||
ICommandHandler<UpdateNameCommand>, | ||
IConsumeEvent<AddedEvent>, | ||
IConsumeEvent<NameChangedEvent> | ||
{ | ||
private bool created; | ||
private string? currentName; | ||
|
||
public void Consume(AddedEvent evt, EventMetadata metadata) | ||
{ | ||
created = true; | ||
currentName = evt.Name; | ||
} | ||
|
||
public void Consume(NameChangedEvent evt, EventMetadata metadata) | ||
{ | ||
currentName = evt.NewName; | ||
} | ||
|
||
public ValueTask ExecuteAsync( | ||
UpdateNameCommand command, | ||
ICommandContext context, | ||
CancellationToken cancellationToken) | ||
{ | ||
if (!created) | ||
{ | ||
throw new InvalidOperationException("Cannot change name on non-existing entity."); | ||
} | ||
|
||
if (currentName != command.Name) | ||
{ | ||
context.AddEvent(new NameChangedEvent(currentName!, command.Name)); | ||
} | ||
|
||
return ValueTask.CompletedTask; | ||
} | ||
} |
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,44 @@ | ||
using Atc.Cosmos.EventStore.Cqrs; | ||
using Microsoft.Extensions.Hosting; | ||
|
||
namespace GettingStarted; | ||
|
||
public class ConsoleHostedService(ICommandProcessorFactory commandProcessorFactory) : IHostedService | ||
{ | ||
public async Task StartAsync(CancellationToken cancellationToken) | ||
{ | ||
var id = Guid.NewGuid().ToString("N"); | ||
|
||
await commandProcessorFactory | ||
.Create<CreateCommand>() | ||
.ExecuteAsync( | ||
new CreateCommand(id, "First", "Address 1"), | ||
cancellationToken); | ||
|
||
await commandProcessorFactory | ||
.Create<UpdateNameCommand>() | ||
.ExecuteAsync( | ||
new UpdateNameCommand(id, "Second"), | ||
cancellationToken); | ||
|
||
await commandProcessorFactory | ||
.Create<UpdateNameCommand>() | ||
.ExecuteAsync( | ||
new UpdateNameCommand(id, "Third"), | ||
cancellationToken); | ||
|
||
await commandProcessorFactory | ||
.Create<DeleteCommand>() | ||
.ExecuteAsync( | ||
new DeleteCommand(id, "Deleted"), | ||
cancellationToken); | ||
|
||
await commandProcessorFactory | ||
.Create<DeleteCommand>() | ||
.ExecuteAsync( | ||
new DeleteCommand(id, "Deleted"), | ||
cancellationToken); | ||
} | ||
|
||
public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask; | ||
} |
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,6 @@ | ||
using Atc.Cosmos.EventStore.Cqrs; | ||
|
||
namespace GettingStarted; | ||
|
||
[StreamEvent("added-event:v1")] | ||
public record AddedEvent(string Name, string Address); |
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,6 @@ | ||
using Atc.Cosmos.EventStore.Cqrs; | ||
|
||
namespace GettingStarted; | ||
|
||
[StreamEvent("address-changed-event:v1")] | ||
public record AddressChangedEvent(string OldAddress, string NewAddress); |
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,6 @@ | ||
using Atc.Cosmos.EventStore.Cqrs; | ||
|
||
namespace GettingStarted; | ||
|
||
[StreamEvent("deleted-event:v1")] | ||
public record DeletedEvent(string Reason); |
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,6 @@ | ||
using Atc.Cosmos.EventStore.Cqrs; | ||
|
||
namespace GettingStarted; | ||
|
||
[StreamEvent("name-changed-event:v1")] | ||
public record NameChangedEvent(string OldName, string NewName); |
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,17 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<LangVersion>latest</LangVersion> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Atc.Cosmos" Version="1.1.40" /> | ||
<PackageReference Include="Atc.Cosmos.EventStore.Cqrs" Version="1.12.6" /> | ||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Oops, something went wrong.