-
-
Notifications
You must be signed in to change notification settings - Fork 467
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new, improved, separate store aware, multi-database aware 'projection…
…s' command. Closes GH-2266
- Loading branch information
1 parent
2942b0f
commit d805795
Showing
44 changed files
with
1,662 additions
and
387 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using System.Threading.Tasks.Dataflow; | ||
using Baseline; | ||
using Spectre.Console; | ||
|
||
namespace EventPublisher | ||
{ | ||
public class StatusBoard | ||
{ | ||
private readonly LightweightCache<string, ProjectionStatus> _counts; | ||
private StatusContext _context; | ||
private readonly ActionBlock<UpdateMessage> _updater; | ||
|
||
public StatusBoard(Task completion) | ||
{ | ||
_counts = new(name => new ProjectionStatus(name, completion)); | ||
_updater = new ActionBlock<UpdateMessage>(Update, | ||
new ExecutionDataflowBlockOptions { MaxDegreeOfParallelism = 1, EnsureOrdered = true }); | ||
|
||
} | ||
|
||
public record UpdateMessage(string Name, int Count); | ||
|
||
public void Update(UpdateMessage message) | ||
{ | ||
_counts[message.Name].Update(message.Count); | ||
} | ||
|
||
public void Update(string name, int count) | ||
{ | ||
_updater.Post(new UpdateMessage(name, count)); | ||
} | ||
} | ||
|
||
|
||
public class ProjectionStatus | ||
{ | ||
private readonly string _name; | ||
private StatusContext _context; | ||
private int _count; | ||
|
||
public ProjectionStatus(string name, Task completion) | ||
{ | ||
_name = name; | ||
|
||
AnsiConsole | ||
.Status() | ||
.AutoRefresh(true) | ||
.StartAsync("Waiting...", context => | ||
{ | ||
context.Spinner(Spinner.Known.Clock); | ||
context.SpinnerStyle(Style.Parse("grey italic")); | ||
context.Refresh(); | ||
_context = context; | ||
return completion; | ||
}); | ||
} | ||
|
||
public void Update(int count) | ||
{ | ||
_count += count; | ||
|
||
if (_context == null) return; | ||
_context.Spinner(Spinner.Known.Default); | ||
_context.SpinnerStyle(Style.Plain); | ||
_context.Status = $"{_name}: {_count}"; | ||
|
||
_context.Refresh(); | ||
} | ||
|
||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/Marten.CommandLine.Tests/Marten.CommandLine.Tests.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,33 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
|
||
<IsPackable>false</IsPackable> | ||
|
||
<LangVersion>10</LangVersion> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" /> | ||
<PackageReference Include="NSubstitute" Version="4.3.0" /> | ||
<PackageReference Include="Shouldly" Version="4.0.3" /> | ||
<PackageReference Include="xunit" Version="2.4.1" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="coverlet.collector" Version="3.1.2"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Marten.CommandLine\Marten.CommandLine.csproj" /> | ||
<ProjectReference Include="..\Marten.Testing\Marten.Testing.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Oops, something went wrong.