Skip to content

Commit

Permalink
Merge pull request #56 from atc-net/release/v1.14
Browse files Browse the repository at this point in the history
Release of new minor version v1.14
  • Loading branch information
LarsSkovslund authored Dec 9, 2024
2 parents 52c1cb8 + 4da39a6 commit 6e0f93c
Show file tree
Hide file tree
Showing 48 changed files with 814 additions and 175 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/verification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,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: 🛠️ Building libraries in release mode
run: dotnet build -c release -p:ContinuousIntegrationBuild=true
Expand Down
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Implement `IEventStoreManagementClient.DeleteStreamAsync` using the newly released `DeleteAllItemsByPartitionKeyStreamAsync` method in the Cosmos SDK.
- Extend `CommandContext` with the current `StreamVersion` of the stream.

## [1.13.3] - 2024-04-21

### Added
Expand Down Expand Up @@ -187,4 +192,4 @@ services.AddEventStore(builder =>

[1.3.3]: https://github.com/atc-net/atc-cosmos-eventstore/compare/v1.2.9...v1.3.3

[1.2.9]: https://github.com/atc-net/atc-cosmos-eventstore/compare/v1.1.3...v1.2.9
[1.2.9]: https://github.com/atc-net/atc-cosmos-eventstore/compare/v1.1.3...v1.2.9
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</PropertyGroup>

<PropertyGroup Label="Analyzer settings">
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
<AnalysisMode>Default</AnalysisMode>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<AnalysisLevel>latest</AnalysisLevel>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
Expand Down
80 changes: 0 additions & 80 deletions sample/.editorconfig

This file was deleted.

31 changes: 31 additions & 0 deletions sample/GettingStarted/Commands/CreateCommands.cs
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;
}
}
44 changes: 44 additions & 0 deletions sample/GettingStarted/Commands/DeleteCommand.cs
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;
}
}
44 changes: 44 additions & 0 deletions sample/GettingStarted/Commands/UpdateNameCommands.cs
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;
}
}
44 changes: 44 additions & 0 deletions sample/GettingStarted/ConsoleHostedService.cs
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;
}
6 changes: 6 additions & 0 deletions sample/GettingStarted/Events/AddedEvent.cs
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);
6 changes: 6 additions & 0 deletions sample/GettingStarted/Events/AddressChangedEvent.cs
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);
6 changes: 6 additions & 0 deletions sample/GettingStarted/Events/DeletedEvent.cs
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);
6 changes: 6 additions & 0 deletions sample/GettingStarted/Events/NameChangedEvent.cs
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);
17 changes: 17 additions & 0 deletions sample/GettingStarted/GettingStarted.csproj
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>
Loading

0 comments on commit 6e0f93c

Please sign in to comment.