-
-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add base SQL classes * Added polling query incremental delays to subscriptions, fixes #224 * Allow subscriptions to restart properly * Added TaskRunner * [BREAKING] Adding stream name going back and forth but at least it will be consistent * [BREAKING] Changed the SQL Server config to use the connection string * Added SQL Server DI registrations similar to Postgres
- Loading branch information
1 parent
1f3152f
commit bd59c90
Showing
82 changed files
with
1,375 additions
and
1,315 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright (C) Ubiquitous AS.All rights reserved | ||
// Licensed under the Apache License, Version 2.0. | ||
|
||
namespace Eventuous.Tools; | ||
|
||
public sealed class TaskRunner(Func<CancellationToken, Task> taskFactory) : IDisposable { | ||
readonly CancellationTokenSource _stopSource = new(); | ||
|
||
Task? _runner; | ||
|
||
public TaskRunner Start() { | ||
_runner = Task.Run(Run); | ||
|
||
return this; | ||
|
||
async Task Run() { | ||
try { | ||
await taskFactory(_stopSource.Token); | ||
} catch (OperationCanceledException) { | ||
// ignore | ||
} | ||
} | ||
} | ||
|
||
public async ValueTask Stop(CancellationToken cancellationToken) { | ||
if (_runner == null) return; | ||
|
||
try { | ||
#if NET8_0_OR_GREATER | ||
await _stopSource.CancelAsync(); | ||
#else | ||
_stopSource.Cancel(); | ||
#endif | ||
// if (_runner != null) await _runner.NoContext(); | ||
} finally { | ||
var state = new TaskCompletionSource<object>(); | ||
var registration = cancellationToken.Register((s => (((TaskCompletionSource<object>)s!)!).SetCanceled(cancellationToken)), state); | ||
|
||
try { | ||
await Task.WhenAny(_runner, state.Task).NoContext(); | ||
} finally { | ||
await registration.DisposeAsync(); | ||
} | ||
|
||
registration = new CancellationTokenRegistration(); | ||
} | ||
} | ||
|
||
public void Dispose() { | ||
_stopSource.Dispose(); | ||
_runner?.Dispose(); | ||
} | ||
} |
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 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
11 changes: 11 additions & 0 deletions
11
src/Core/test/Eventuous.Tests.Persistence.Base/Eventuous.Tests.Persistence.Base.csproj
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,11 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<IncludeSutSubs>true</IncludeSutSubs> | ||
<IncludeSutApp>true</IncludeSutApp> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="NodaTime.Serialization.SystemTextJson" /> | ||
<PackageReference Include="MicroElements.AutoFixture.NodaTime" /> | ||
<PackageReference Include="Testcontainers" /> | ||
</ItemGroup> | ||
</Project> |
Oops, something went wrong.