Skip to content

WIP: [DEVEX-227] Getting state from events and running busines logic #334

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 46 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
7029ca7
moved all files into EventStore.Client project
RagingKore Dec 16, 2024
2cdf1f0
moved files into main project and deleted remaining empty projects
RagingKore Dec 18, 2024
bd6b10f
Remove unused target frameworks and pass certificate in healthcheck
w1am Dec 20, 2024
0c2d0e3
Tests
w1am Jan 6, 2025
ebc6e60
Rename test symbols
w1am Jan 7, 2025
a0dd296
Merge branch 'master' of github.com:EventStore/EventStore-Client-Dotn…
w1am Jan 7, 2025
740872b
Test workflow
w1am Jan 7, 2025
f68cec0
Testing something
w1am Jan 7, 2025
7699152
More tests
w1am Jan 7, 2025
4c238c7
Improve CI
w1am Jan 8, 2025
9c693e6
Merge branch 'master' of github.com:EventStore/EventStore-Client-Dotn…
w1am Jan 8, 2025
b278f7d
Improve CI
w1am Jan 8, 2025
fd0b009
Fixup
w1am Jan 8, 2025
d613ba3
Publish actions
w1am Jan 8, 2025
d98910a
Temporarily disable Public actions
w1am Jan 8, 2025
d62b558
Fixup
w1am Jan 8, 2025
55d1547
Test warmup
w1am Jan 9, 2025
44607ea
[DEVEX-222] Add built-in auto-serialization (#329)
oskardudycz Feb 27, 2025
07a8d87
Revert "[DEVEX-222] Add built-in auto-serialization (#329)" (#332)
w1am Feb 27, 2025
dc14196
[DEVEX-222] Add built-in auto-serialization (#333)
w1am Feb 27, 2025
89628d2
[DEVEX-227] Added BuildStateOptions
oskardudycz Jan 23, 2025
688f934
[DEVEX-227] Added BuildStateOptions
oskardudycz Feb 14, 2025
ead7b53
[DEVEX-227] Removed build state options and expanded build state exte…
oskardudycz Feb 21, 2025
58df83d
[DEVEX-227] Moved state building to dedicated method and shared it be…
oskardudycz Feb 21, 2025
67bfbfe
[DEVEX-227] Added sample domain structure for building state in vario…
oskardudycz Feb 24, 2025
1ab79bb
[DEVEX-227] Reshaped files structure and split code for state buildin…
oskardudycz Feb 27, 2025
89aa392
[DEVEX-227] Added capability to build state from snapshot
oskardudycz Feb 28, 2025
d879997
[DEVEX-227] Added IAggregate abstractions, State and Aggregate Stores
oskardudycz Mar 5, 2025
22c7427
[DEVEX-227] Cleaned up Getting Snapshot usage to make it more focused
oskardudycz Mar 5, 2025
44e3254
[DEVEX-227] Trimmed and refactored Decision logic
oskardudycz Mar 5, 2025
54330b9
[DEVEX-227] Added option to Project state, and get a continues stream…
oskardudycz Mar 5, 2025
11b9a67
[DEVEX-227] Adjusted Decision making tests to show the example usage
oskardudycz Mar 5, 2025
081d91f
[DEVEX-227] Added Add, Update methods to StateStore and AggregateStore
oskardudycz Mar 6, 2025
cc77373
[DEVEX-227] Made Aggregate return messages and separated AggregateSto…
oskardudycz Mar 6, 2025
a84083a
[DEVEX-227] Refactored State Store extracting interface and moving th…
oskardudycz Mar 6, 2025
48cec84
[DEVEX-227] Made StateStore default Handle method use messages, added…
oskardudycz Mar 6, 2025
efdf35b
[DEVEX-227] Added AppendToStream options to Decide options
oskardudycz Mar 7, 2025
4444c8c
[DEVEX-227] Added Polly to support retries of business logic
oskardudycz Mar 7, 2025
3644406
[DEVEX-227] Added retry policy handling for optimistic concurrency of…
oskardudycz Mar 7, 2025
dd8cf4c
[DEVEX-227] Updated ProjectState to keep dictionary of states instead…
oskardudycz Mar 7, 2025
f983649
[DEVEX-227] Added state cache for ProjectState function
oskardudycz Mar 7, 2025
0a5bc23
[DEVEX-227] Moved code responsible for GettingState to a dedicated file
oskardudycz Mar 7, 2025
1f6f829
[DEVEX-227] Added missing options in Get state methods of State and A…
oskardudycz Mar 7, 2025
d2f9d4e
[DEVEX-227] Added example of Decider
oskardudycz Mar 7, 2025
3d76fbb
[DEVEX-227] Added example of handling Aggregate and AggregateStore
oskardudycz Mar 7, 2025
d89abce
[DEVEX-227] Added example of state projection
oskardudycz Mar 7, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Test workflow
  • Loading branch information
w1am committed Jan 7, 2025
commit 740872b0d00de2ca3bd419589856a8df3e684276
1 change: 1 addition & 0 deletions .github/workflows/base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ jobs:
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
8.0.x
9.0.x
- name: Run Tests
shell: bash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ protected KurrentPermanentFixture(ConfigureFixture configure) {

public ILogger Log => Logger;

public ITestService Service { get; }
public ITestService Service { get; }
public KurrentFixtureOptions Options { get; }
public Faker Faker { get; } = new Faker();
public Faker Faker { get; } = new Faker();

public Version EventStoreVersion { get; private set; } = null!;
// public Version EventStoreVersion { get; private set; } = null!;
public bool EventStoreHasLastStreamPosition { get; private set; }

public KurrentClient Streams { get; private set; } = null!;
Expand Down Expand Up @@ -87,13 +87,13 @@ public async Task InitializeAsync() {
await ContainerSemaphore.WaitAsync();
try {
await Service.Start();
// EventStoreVersion = GetEventStoreVersion();
// EventStoreHasLastStreamPosition = (EventStoreVersion?.Major ?? int.MaxValue) >= 21;
EventStoreHasLastStreamPosition = true;
} finally {
ContainerSemaphore.Release();
}

EventStoreVersion = GetEventStoreVersion();
EventStoreHasLastStreamPosition = (EventStoreVersion?.Major ?? int.MaxValue) >= 21;

await WarmUpGatekeeper.WaitAsync();

try {
Expand Down Expand Up @@ -133,36 +133,36 @@ async Task<T> InitClient<T>(Func<T, Task> action, bool execute = true) where T :
return client;
}

static Version GetEventStoreVersion() {
const string versionPrefix = "EventStoreDB version";

using var cancellator = new CancellationTokenSource(FromSeconds(30));
using var eventstore = new Builder()
.UseContainer()
.UseImage(GlobalEnvironment.DockerImage)
.Command("--version")
.Build()
.Start();

using var log = eventstore.Logs(true, cancellator.Token);
foreach (var line in log.ReadToEnd()) {
if (line.StartsWith(versionPrefix) &&
Version.TryParse(
new string(ReadVersion(line[(versionPrefix.Length + 1)..]).ToArray()),
out var version
)) {
return version;
}
}

throw new InvalidOperationException("Could not determine server version.");

IEnumerable<char> ReadVersion(string s) {
foreach (var c in s.TakeWhile(c => c == '.' || char.IsDigit(c))) {
yield return c;
}
}
}
// static Version GetEventStoreVersion() {
// const string versionPrefix = "EventStoreDB version";
//
// using var cancellator = new CancellationTokenSource(FromSeconds(30));
// using var eventstore = new Builder()
// .UseContainer()
// .UseImage(GlobalEnvironment.DockerImage)
// .Command("--version")
// .Build()
// .Start();
//
// using var log = eventstore.Logs(true, cancellator.Token);
// foreach (var line in log.ReadToEnd()) {
// if (line.StartsWith(versionPrefix) &&
// Version.TryParse(
// new string(ReadVersion(line[(versionPrefix.Length + 1)..]).ToArray()),
// out var version
// )) {
// return version;
// }
// }
//
// throw new InvalidOperationException("Could not determine server version.");
//
// IEnumerable<char> ReadVersion(string s) {
// foreach (var c in s.TakeWhile(c => c == '.' || char.IsDigit(c))) {
// yield return c;
// }
// }
// }
}

public async Task DisposeAsync() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ protected KurrentTemporaryFixture(ConfigureFixture configure) {

public ILogger Log => Logger;

public ITestService Service { get; }
public ITestService Service { get; }
public KurrentFixtureOptions Options { get; }
public Faker Faker { get; } = new Faker();
public Faker Faker { get; } = new Faker();

public Version EventStoreVersion { get; private set; } = null!;
// public Version EventStoreVersion { get; private set; } = null!;
public bool EventStoreHasLastStreamPosition { get; private set; }

public KurrentClient Streams { get; private set; } = null!;
Expand Down Expand Up @@ -89,13 +89,13 @@ public async Task InitializeAsync() {
await ContainerSemaphore.WaitAsync();
try {
await Service.Start();
// EventStoreVersion = GetEventStoreVersion();
// EventStoreHasLastStreamPosition = (EventStoreVersion?.Major ?? int.MaxValue) >= 21;
EventStoreHasLastStreamPosition = true;
} finally {
ContainerSemaphore.Release();
}

EventStoreVersion = GetEventStoreVersion();
EventStoreHasLastStreamPosition = (EventStoreVersion?.Major ?? int.MaxValue) >= 21;

await WarmUpGatekeeper.WaitAsync();

try {
Expand Down Expand Up @@ -135,36 +135,36 @@ async Task<T> InitClient<T>(Func<T, Task> action, bool execute = true) where T :
return client;
}

static Version GetEventStoreVersion() {
const string versionPrefix = "EventStoreDB version";

using var cancellator = new CancellationTokenSource(FromSeconds(30));
using var eventstore = new Builder()
.UseContainer()
.UseImage(GlobalEnvironment.DockerImage)
.Command("--version")
.Build()
.Start();

using var log = eventstore.Logs(true, cancellator.Token);
foreach (var line in log.ReadToEnd()) {
if (line.StartsWith(versionPrefix) &&
Version.TryParse(
new string(ReadVersion(line[(versionPrefix.Length + 1)..]).ToArray()),
out var version
)) {
return version;
}
}

throw new InvalidOperationException("Could not determine server version.");

IEnumerable<char> ReadVersion(string s) {
foreach (var c in s.TakeWhile(c => c == '.' || char.IsDigit(c))) {
yield return c;
}
}
}
// static Version GetEventStoreVersion() {
// const string versionPrefix = "EventStoreDB version";
//
// using var cancellator = new CancellationTokenSource(FromSeconds(30));
// using var eventstore = new Builder()
// .UseContainer()
// .UseImage(GlobalEnvironment.DockerImage)
// .Command("--version")
// .Build()
// .Start();
//
// using var log = eventstore.Logs(true, cancellator.Token);
// foreach (var line in log.ReadToEnd()) {
// if (line.StartsWith(versionPrefix) &&
// Version.TryParse(
// new string(ReadVersion(line[(versionPrefix.Length + 1)..]).ToArray()),
// out var version
// )) {
// return version;
// }
// }
//
// throw new InvalidOperationException("Could not determine server version.");
//
// IEnumerable<char> ReadVersion(string s) {
// foreach (var c in s.TakeWhile(c => c == '.' || char.IsDigit(c))) {
// yield return c;
// }
// }
// }
}

public async Task DisposeAsync() {
Expand Down
Loading