Permalink
Browse files

Grand Clean Up

  • Loading branch information...
yevhen committed Aug 20, 2017
1 parent 2b50004 commit c7fcb02437601cb8a5851aa0878175aa6e2bb8cf
Showing with 1,357 additions and 968 deletions.
  1. +18 −34 Nake.csx
  2. +6 −3 README.md
  3. +10 −0 Source/Example/Example.csproj
  4. +10 −8 Source/Example/Program.cs
  5. +4 −3 Source/Example/Scenario.cs
  6. +4 −4 Source/Example/Scenarios/S01_Provision_new_stream.cs
  7. +9 −9 Source/Example/Scenarios/S02_Open_stream_for_writing.cs
  8. +9 −9 Source/Example/Scenarios/S03_Try_open_stream_for_writing.cs
  9. +37 −39 Source/Example/Scenarios/S04_Write_to_stream.cs
  10. +13 −12 Source/Example/Scenarios/S05_Read_from_stream.cs
  11. +6 −6 Source/Example/Scenarios/S06_Include_additional_entities.cs
  12. +17 −17 Source/Example/Scenarios/S07_Custom_stream_metadata.cs
  13. +23 −23 Source/Example/Scenarios/S08_Concurrency_conflicts.cs
  14. +4 −4 Source/Example/Scenarios/S09_Handling_duplicates.cs
  15. +30 −31 Source/Example/Scenarios/S10_Stream_directory.cs
  16. +7 −6 Source/Example/Scenarios/S11_Sharding_streams.cs
  17. +2 −9 Source/Streamstone.Tests/Api.cs
  18. +4 −2 Source/Streamstone.Tests/Scenarios/Checking_stream_exists.cs
  19. +1 −1 Source/Streamstone.Tests/Scenarios/Custom_event_properties.cs
  20. +5 −4 Source/Streamstone.Tests/Scenarios/Including_additional_entities.cs
  21. +1 −1 Source/Streamstone.Tests/Scenarios/Opening_stream.cs
  22. +4 −2 Source/Streamstone.Tests/Scenarios/Provisioning_stream.cs
  23. +1 −1 Source/Streamstone.Tests/Scenarios/Reading_from_stream.cs
  24. +1 −1 Source/Streamstone.Tests/Scenarios/Setting_stream_properties.cs
  25. +63 −61 Source/Streamstone.Tests/Scenarios/Tracking_entity_changes.cs
  26. +3 −3 Source/Streamstone.Tests/Scenarios/Virtual_partitions.cs
  27. +8 −8 Source/Streamstone.Tests/Scenarios/Writing_to_stream.cs
  28. +4 −9 Source/Streamstone.Tests/Storage.cs
  29. +2 −0 Source/Streamstone.Tests/Streamstone.Tests.csproj
  30. +13 −38 Source/Streamstone/Event.cs
  31. +1 −1 Source/Streamstone/EventId.cs
  32. +2 −2 Source/Streamstone/EventIncludes.cs
  33. +3 −3 Source/Streamstone/EventProperties.cs
  34. +0 −18 Source/Streamstone/Extensions.cs
  35. +9 −21 Source/Streamstone/Include.cs
  36. +9 −23 Source/Streamstone/Partition.cs
  37. +14 −30 Source/Streamstone/PropertyMap.cs
  38. +16 −304 Source/Streamstone/Stream.Api.cs
  39. +10 −22 Source/Streamstone/Stream.Header.cs
  40. +28 −159 Source/Streamstone/Stream.Operations.cs
  41. +4 −4 Source/Streamstone/StreamProperties.cs
  42. +4 −2 Source/Streamstone/Streamstone.csproj
  43. +9 −31 Source/Streamstone/Utility.cs
  44. +929 −0 Streamstone.sln.DotSettings
  45. BIN Tools/NuGet.exe
@@ -5,6 +5,7 @@ using System.Linq;
using System.Net;
using System.Xml.Linq;
using System.Diagnostics;
using System.Text.RegularExpressions;
using static Nake.App;
using static Nake.Env;
@@ -15,58 +16,41 @@ using static Nake.Run;
const string Project = "Streamstone";
const string RootPath = "%NakeScriptDirectory%";
const string OutputPath = RootPath + @"\Output";
const string PackagePath = OutputPath + @"\Package";
const string ReleasePath = PackagePath + @"\Release";
var AppVeyor = Var["APPVEYOR"] == "True";
/// Builds sources in Debug mode
[Task] void Default()
{
Build();
}
/// Wipeout all build output and temporary build files
[Step] void Clean(string path = OutputPath)
{
Delete(@"{path}\*.*|-:*.vshost.exe");
}
[Task] void Default() => Build();
/// Builds sources using specified configuration and output path
[Step] void Build(string config = "Debug", string outDir = OutputPath)
{
Clean(outDir);
Exec("dotnet", "build {Project}.sln /p:Configuration={config};OutDir={outDir};ReferencePath={outDir}");
}
[Step] void Build(string config = "Debug") =>
Exec("dotnet", "build {Project}.sln /p:Configuration={config}");
/// Runs unit tests
[Step] void Test(string outDir = OutputPath)
[Step] void Test()
{
Console.WriteLine(outDir);
Exec("dotnet", "test Source/Streamstone.Tests/Streamstone.Tests.csproj -l:trx;LogFileName=nunit-test-results.trx --results-directory \"{outDir}\"");
Exec("dotnet", "test Source/Streamstone.Tests/Streamstone.Tests.csproj --configuration Debug -l:trx;LogFileName=nunit-test-results.trx --results-directory \"{OutputPath}\"");
var results = @"{outDir}\nunit-test-results.trx";
var results = @"{OutputPath}\nunit-test-results.trx";
if (AppVeyor)
new WebClient().UploadFile("https://ci.appveyor.com/api/testresults/mstest/%APPVEYOR_JOB_ID%", results);
}
/// Builds official NuGet package
[Step] void Package()
{
Test(PackagePath + @"\Debug");
Build("Release", ReleasePath);
Exec("dotnet", @"pack Source/Streamstone/Streamstone.csproj /p:PackageVersion={Version()} --configuration Release --output ""{PackagePath}""");
Test();
Exec("dotnet", @"pack Source/Streamstone/Streamstone.csproj /p:PackageVersion={Version()} --configuration Release --output ""{OutputPath}""");
}
/// Publishes package to NuGet gallery
[Step] void Publish()
{
Cmd(@"Tools\Nuget.exe push {PackagePath}\{Project}.{Version()}.nupkg %NuGetApiKey%");
}
[Step] void Publish() => Cmd(@"Tools\Nuget.exe push {OutputPath}\{Project}.{Version()}.nupkg %NuGetApiKey% -Source https://nuget.org/");
string Version()
{
var version = File
.ReadAllLines(@"{RootPath}\Source\Streamstone.Version.cs")
.First(x => x.StartsWith("[assembly: AssemblyVersion("));
string Version() => FileVersionInfo
.GetVersionInfo(@"{ReleasePath}\{Project}.dll")
.FileVersion;
return new Regex(@"AssemblyVersion\(\""([^\""]*)\""\)").Match(version).Groups[1].Value;
}
@@ -15,6 +15,7 @@ Streamstone is a small library targeted at building scalable event-sourced appli
+ Change tracking support for inline projections
+ Friendly for multi-tenant designs
+ Sharding support (jump consistent hashing)
+ Compatible with .NET Standard 1.6 and higher
## Installing from NuGet [![NuGet](https://img.shields.io/nuget/v/Streamstone.svg?style=flat)](https://www.nuget.org/packages/Streamstone/)
@@ -24,13 +25,15 @@ To install Streamstone via NuGet, run this command in NuGet package manager cons
## Building from source [![Build status](https://ci.appveyor.com/api/projects/status/3rsmwblor11b6inq/branch/master?svg=true)](https://ci.appveyor.com/project/yevhen/streamstone/branch/master)
To build Streamstone's binaries, just clone the repository and build solution from Visual Studio (2015, 2017, .NET 4.6), Alternatively, run the following command from solution's root directory:
NOTE: Currently automated build scripts can be run only on Windows but it's possible to produce binary on Linux by using dotnet cli tooling (ie `dotnet build`). To build Streamstone binaries on Windows you will need to have Visual Studio 17 Update 3 or higher, .NET Core SDK 2.0 and .NET Framework 4.6.1 or higher.
> Nake.bat
To build Streamstone from cli on Windows, run the following command from solution's root directory:
> Nake.bat package
For a list of available commands run `Nake.bat -T`.
> NOTE: To run unit tests you will need to have Azure Storage Emulator 5.1 or higher. Alternatively, you could run unit tests against real storage by setting storage account connection string to **Streamstone-Test-Storage** user-level environment variable.
> NOTE: To run unit tests you will need to have Azure Storage Emulator 5.2 or higher. Alternatively, you could run unit tests against real storage by setting storage account connection string to **Streamstone-Test-Storage** user-level environment variable.
## Design
@@ -2,7 +2,17 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<StartupObject>Example.Program</StartupObject>
<LangVersion>7.1</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<TargetFramework>net461</TargetFramework>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<TargetFramework>netcoreapp2.0</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
@@ -1,16 +1,18 @@
using Example.Scenarios;
using System;
using System.Threading.Tasks;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Table;
using System;
using System.Threading.Tasks;
namespace Example
{
using Scenarios;
class Program
{
static void Main(string[] args)
static async Task Main(string[] args)
{
var table = Prepare().Result;
var table = await Prepare();
var scenarios = new Scenario[]
{
@@ -27,19 +29,19 @@ static void Main(string[] args)
new S11_Sharding_streams(),
};
for (var i = 0; i < scenarios.Length; i++)
foreach (var scenario in scenarios)
{
var scenario = scenarios[i];
var scenarioName = scenario.GetType().Name;
Console.WriteLine("{0}", scenarioName.Replace("_", " "));
Console.WriteLine(new string('-', 40));
scenario.Initialize(table, scenarioName);
scenario.Run();
await scenario.RunAsync();
Console.WriteLine();
}
Console.WriteLine("You can check out the contents of '{0}' table using Server Explorer in VS", table.Name);
Console.WriteLine("Press any key to exit ...");
@@ -1,5 +1,6 @@
using Streamstone;
using System.Threading.Tasks;
using Microsoft.WindowsAzure.Storage.Table;
using Streamstone;
namespace Example
{
@@ -16,6 +17,6 @@ public void Initialize(CloudTable table, string id)
Partition = new Partition(table, id);
}
public abstract void Run();
public abstract Task RunAsync();
}
}
}
@@ -1,21 +1,21 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using Streamstone;
namespace Example.Scenarios
{
public class S01_Provision_new_stream : Scenario
{
public override void Run()
public override async Task RunAsync()
{
var stream = Stream.Provision(Partition);
var stream = await Stream.ProvisionAsync(Partition);
Console.WriteLine("Provisioned new empty stream in partition '{0}'", stream.Partition);
Console.WriteLine("Etag: {0}", stream.ETag);
Console.WriteLine("Version: {0}", stream.Version);
var exists = Stream.Exists(Partition);
var exists = await Stream.ExistsAsync(Partition);
Console.WriteLine("Checking stream exists in a storage: {0}", exists);
}
}
@@ -1,35 +1,35 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using Streamstone;
namespace Example.Scenarios
{
public class S02_Open_stream_for_writing : Scenario
{
public override void Run()
public override async Task RunAsync()
{
OpenNonExistingStream();
OpenExistingStream();
await OpenNonExistingStream();
await OpenExistingStream();
}
void OpenNonExistingStream()
async Task OpenNonExistingStream()
{
try
{
Stream.Open(Partition);
await Stream.OpenAsync(Partition);
}
catch (StreamNotFoundException)
{
Console.WriteLine("Opening non-existing stream will throw StreamNotFoundException");
}
}
void OpenExistingStream()
async Task OpenExistingStream()
{
Stream.Provision(Partition);
await Stream.ProvisionAsync(Partition);
var stream = Stream.Open(Partition);
var stream = await Stream.OpenAsync(Partition);
Console.WriteLine("Opened existing (empty) stream in partition '{0}'", stream.Partition);
Console.WriteLine("Etag: {0}", stream.ETag);
@@ -1,31 +1,31 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using Streamstone;
namespace Example.Scenarios
{
public class S03_Try_open_stream_for_writing : Scenario
{
public override void Run()
public override async Task RunAsync()
{
TryOpenNonExistentStream();
TryOpenExistentStream();
await TryOpenNonExistentStream();
await TryOpenExistentStream();
}
void TryOpenNonExistentStream()
async Task TryOpenNonExistentStream()
{
var existent = Stream.TryOpen(Partition);
var existent = await Stream.TryOpenAsync(Partition);
Console.WriteLine("Trying to open non-existent stream. Found: {0}, Stream: {1}",
existent.Found, existent.Stream == null ? "<null>" : "?!?");
}
void TryOpenExistentStream()
async Task TryOpenExistentStream()
{
Stream.Provision(Partition);
await Stream.ProvisionAsync(Partition);
var existent = Stream.TryOpen(Partition);
var existent = await Stream.TryOpenAsync(Partition);
Console.WriteLine("Trying to open existent stream. Found: {0}, Stream: {1}\r\nEtag - {2}, Version - {3}",
existent.Found, existent.Stream, existent.Stream.ETag, existent.Stream.Version);
Oops, something went wrong.

0 comments on commit c7fcb02

Please sign in to comment.