Skip to content
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

Source link #17

Merged
merged 6 commits into from
Nov 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ root = true
[*]
indent_style = space

# yml files
[*.{yml,yaml}]
indent_size = 2

# XML project files
[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}]
indent_size = 2
Expand Down
12 changes: 8 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ name: Build and test
on:
pull_request:
branches: [ main ]
push:
branches: [ main ]

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
target-framework: [ 'net5.0', 'net6.0' ]

name: Dotnet build and test targetting ${{ matrix.target-framework }}
steps:
- uses: actions/checkout@v2
with:
Expand All @@ -19,7 +21,9 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
dotnet-version: |
5.0.x
6.0.x

- name: Restore dependencies
run: dotnet restore
Expand All @@ -28,4 +32,4 @@ jobs:
run: dotnet build -c Release --no-restore

- name: Test
run: dotnet test -c Release --no-build --verbosity normal --filter "Category!=LongRunning"
run: dotnet test test/Orleans.SyncWork.Tests/Orleans.SyncWork.Tests.csproj -f net6.0 -c Release --no-build --verbosity normal --filter "Category!=LongRunning"
6 changes: 4 additions & 2 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches:
- 'RELEASE/v**'

workflow_dispatch:

jobs:
build:
Expand All @@ -19,7 +19,9 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
dotnet-version: |
5.0.x
6.0.x

- name: Restore dependencies
run: dotnet restore
Expand Down
7 changes: 7 additions & 0 deletions Orleans.SyncWork.sln
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{476ED2F0-1
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Orleans.SyncWork.Tests", "test\Orleans.SyncWork.Tests\Orleans.SyncWork.Tests.csproj", "{45FA9797-D1D9-4DC6-8456-D9B8A9C52102}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Orleans.SyncWork.Demo.Services", "samples\Orleans.SyncWork.Demo.Services\Orleans.SyncWork.Demo.Services.csproj", "{961EF604-582A-461C-90CE-C7FFE6C40769}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -39,6 +41,10 @@ Global
{45FA9797-D1D9-4DC6-8456-D9B8A9C52102}.Debug|Any CPU.Build.0 = Debug|Any CPU
{45FA9797-D1D9-4DC6-8456-D9B8A9C52102}.Release|Any CPU.ActiveCfg = Release|Any CPU
{45FA9797-D1D9-4DC6-8456-D9B8A9C52102}.Release|Any CPU.Build.0 = Release|Any CPU
{961EF604-582A-461C-90CE-C7FFE6C40769}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{961EF604-582A-461C-90CE-C7FFE6C40769}.Debug|Any CPU.Build.0 = Debug|Any CPU
{961EF604-582A-461C-90CE-C7FFE6C40769}.Release|Any CPU.ActiveCfg = Release|Any CPU
{961EF604-582A-461C-90CE-C7FFE6C40769}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -48,6 +54,7 @@ Global
{F3AAFF72-3922-493B-AD5F-BF8B4F7286F7} = {20B3ED9E-B5FB-47A8-B24E-9EED821AEBE3}
{D3E6A078-CF31-44BD-AA4E-8DDB956882D5} = {E908BC7F-91AC-4D75-A06A-97E05E765C17}
{45FA9797-D1D9-4DC6-8456-D9B8A9C52102} = {476ED2F0-1D97-425B-B3B7-3AF0961FE4B7}
{961EF604-582A-461C-90CE-C7FFE6C40769} = {20B3ED9E-B5FB-47A8-B24E-9EED821AEBE3}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {17BB45B7-AC08-488D-905F-11E706140C72}
Expand Down
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ The projects in this repository include:
* [Orleans.SyncWork.Tests](#orleanssyncworktests)
* [Orleans.SyncWork.Demo.Api](#orleanssyncworkdemoapi)
* [Orleans.SyncWork.Demo.Api.Benchmark](#orleanssyncworkdemoapibenchmark)
* [Orleans.SyncWork.Demo.Services](#orleanssyncworkdemoservices)

### Orleans.SyncWork

Expand Down Expand Up @@ -45,7 +46,7 @@ This package introduces a few "requirements" against Orleans:

#### Usage

Extend the base class to implement a long running grain (example: [PasswordVerifier](https://github.com/Kritner/Orleans.SyncWork/blob/main/samples/Orleans.SyncWork.Demo.Api/Services/Grains/PasswordVerifier.cs)).
Extend the base class to implement a long running grain.

```cs
public class PasswordVerifier : SyncWorker<PasswordVerifierRequest, PasswordVerifierResult>, IGrain
Expand Down Expand Up @@ -106,7 +107,7 @@ TODO: still could use a few more unit tests here to if nothing else, document be

### Orleans.SyncWork.Demo.Api

This is a demo of the `ISyncWork<TRequest, TResult>` in action. This project is being used as both a Orleans Silo, and client. In a more real world scenario, the grains and silo would be defined and stood up separately from the consumption of the grains, at least in the situations where I've used this design.
This is a demo of the `ISyncWork<TRequest, TResult>` in action. This project is being used as both a Orleans Silo, and client. Generally you would stand up nodes to the cluster separate from the clients against the cluster. Since we have only one node for testing purposes, this project acts as both the silo host and client.

The [OrleansDashboard](https://github.com/OrleansContrib/OrleansDashboard) is also brought up with the API. You can see an example of hitting an endpoint in which 10k password verification requests are received here:

Expand Down Expand Up @@ -192,3 +193,7 @@ And here are the results:
| OrleansTasks | 2.130 s | 0.0055 s | 0.0084 s |

And of course note, that in the above the Orleans tasks are *limited* to my local cluster. In a more real situation where you have multiple nodes to the cluster, you could expect to get better timing, though you'd probably have to deal more with network latency.

### Orleans.SyncWork.Demo.Services

This project defines several grains to demonstrate the workings of the `Orleans.SyncWork` package, through the Web API, benchmark, and tests.
4 changes: 2 additions & 2 deletions samples/Orleans.SyncWork.Demo.Api.Benchmark/Benchy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
using System.Threading.Tasks;
using BenchmarkDotNet.Attributes;
using Microsoft.Extensions.DependencyInjection;
using Orleans.SyncWork.Demo.Api.Services;
using Orleans.SyncWork.Demo.Api.Services.Grains;
using Orleans.SyncWork.Demo.Services;
using Orleans.SyncWork.Demo.Services.Grains;

namespace Orleans.SyncWork.Demo.Api.Benchmark;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<OutputType>Exe</OutputType>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,18 @@

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BCrypt.Net-Next" Version="4.0.2" />
<PackageReference Include="Microsoft.Orleans.CodeGenerator.MSBuild" Version="3.5.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Orleans.Server" Version="3.5.1" />
<PackageReference Include="OrleansDashboard" Version="3.6.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Orleans.SyncWork\Orleans.SyncWork.csproj" />
<ProjectReference Include="..\Orleans.SyncWork.Demo.Services\Orleans.SyncWork.Demo.Services.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
using Microsoft.Extensions.Logging;
using Orleans.Configuration;
using Orleans.Hosting;
using Orleans.SyncWork.Demo.Api.Services;
using Orleans.SyncWork.Demo.Api.Services.Grains;
using Orleans.SyncWork.Demo.Services;
using Orleans.SyncWork.Demo.Services.Grains;
using Orleans.SyncWork.ExtensionMethods;

namespace Orleans.SyncWork.Demo.Api
Expand Down
2 changes: 1 addition & 1 deletion samples/Orleans.SyncWork.Demo.Api/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using Orleans;
using Orleans.SyncWork;
using Orleans.SyncWork.Demo.Api;
using Orleans.SyncWork.Demo.Api.Services.Grains;
using Orleans.SyncWork.Demo.Services.Grains;

var builder = WebApplication.CreateBuilder(args);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Threading.Tasks;

namespace Orleans.SyncWork.Demo.Api.Services.Grains
namespace Orleans.SyncWork.Demo.Services.Grains
{
public class HelloWorld : Grain, IHelloWorld
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Threading.Tasks;

namespace Orleans.SyncWork.Demo.Api.Services.Grains;
namespace Orleans.SyncWork.Demo.Services.Grains;

public interface IHelloWorld : IGrainWithGuidKey
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;

namespace Orleans.SyncWork.Demo.Api.Services.Grains;
namespace Orleans.SyncWork.Demo.Services.Grains;

public class PasswordVerifier : SyncWorker<PasswordVerifierRequest, PasswordVerifierResult>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Threading.Tasks;

namespace Orleans.SyncWork.Demo.Api.Services;
namespace Orleans.SyncWork.Demo.Services;

/// <summary>
/// Represents the contact for verifying a password.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net5.0;net6.0</TargetFrameworks>
<LangVersion>10</LangVersion>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BCrypt.Net-Next" Version="4.0.2" />
<PackageReference Include="Microsoft.Orleans.Core.Abstractions" Version="3.1.0" />
<PackageReference Include="Microsoft.Orleans.CodeGenerator.MSBuild" Version="3.1.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Orleans.SyncWork\Orleans.SyncWork.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Threading.Tasks;

namespace Orleans.SyncWork.Demo.Api.Services;
namespace Orleans.SyncWork.Demo.Services;

public class PasswordVerifier : IPasswordVerifier
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;

namespace Orleans.SyncWork.Demo.Api.Services.TestGrains;
namespace Orleans.SyncWork.Demo.Services.TestGrains;

public class TestGrainException : Exception
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;

namespace Orleans.SyncWork.Demo.Api.Services.TestGrains;
namespace Orleans.SyncWork.Demo.Services.TestGrains;

public class TestDelaySuccessRequest
{
Expand Down
22 changes: 15 additions & 7 deletions src/Orleans.SyncWork/Orleans.SyncWork.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net5.0;net6.0</TargetFrameworks>
<LangVersion>10</LangVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>

<Authors>Kritner</Authors>
<Company>Kritner</Company>
<Description>Provides an abstract base class grain to use for dispatching potentially long running, CPU bound work to an Orleans cluster.</Description>
Expand All @@ -14,22 +20,24 @@
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>

<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<PackageProjectUrl>https://github.com/Kritner/Orleans.SyncWork</PackageProjectUrl>
<RepositoryUrl>https://github.com/Kritner/Orleans.SyncWork</RepositoryUrl>

<Version>1.0.0</Version>

</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.Orleans.Core" Version="3.5.1" />
<PackageReference Include="Microsoft.Orleans.Core.Abstractions" Version="3.5.1" />
<PackageReference Include="Microsoft.Orleans.Runtime.Abstractions" Version="3.5.1" />
<PackageReference Include="Microsoft.Orleans.CodeGenerator.MSBuild" Version="3.5.1">
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="3.1.0" />
<PackageReference Include="Microsoft.Orleans.CodeGenerator.MSBuild" Version="3.1.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Orleans.Core" Version="3.1.0" />
<PackageReference Include="Microsoft.Orleans.Core.Abstractions" Version="3.1.0" />
<PackageReference Include="Microsoft.Orleans.Runtime.Abstractions" Version="3.1.0" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All"/>
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion test/Orleans.SyncWork.Tests/BCryptAssumptionTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using FluentAssertions;
using Orleans.SyncWork.Demo.Api.Services;
using Orleans.SyncWork.Demo.Services;
using Xunit;

namespace Orleans.SyncWork.Tests;
Expand Down
2 changes: 1 addition & 1 deletion test/Orleans.SyncWork.Tests/HelloWorldTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.Threading.Tasks;
using FluentAssertions;
using Orleans.SyncWork.Demo.Api.Services.Grains;
using Orleans.SyncWork.Demo.Services.Grains;
using Orleans.SyncWork.Tests.TestClusters;
using Xunit;

Expand Down
5 changes: 3 additions & 2 deletions test/Orleans.SyncWork.Tests/Orleans.SyncWork.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net5.0;net6.0</TargetFrameworks>
<LangVersion>10</LangVersion>
<IsPackable>false</IsPackable>
</PropertyGroup>

Expand All @@ -21,7 +22,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\samples\Orleans.SyncWork.Demo.Api\Orleans.SyncWork.Demo.Api.csproj" />
<ProjectReference Include="..\..\samples\Orleans.SyncWork.Demo.Services\Orleans.SyncWork.Demo.Services.csproj" />
<ProjectReference Include="..\..\src\Orleans.SyncWork\Orleans.SyncWork.csproj" />
</ItemGroup>

Expand Down
6 changes: 3 additions & 3 deletions test/Orleans.SyncWork.Tests/SyncWorkerExtensionMethodTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
using System.Threading.Tasks;
using BCrypt.Net;
using FluentAssertions;
using Orleans.SyncWork.Demo.Api.Services;
using Orleans.SyncWork.Demo.Api.Services.Grains;
using Orleans.SyncWork.Demo.Services;
using Orleans.SyncWork.Demo.Services.Grains;
using Orleans.SyncWork.Tests.TestClusters;
using Xunit;

namespace Orleans.SyncWork.Tests;

/// <summary>
/// This test class is not *necessarily* specific the the <see cref="Orleans.SyncWork.Demo.Api.Services.PasswordVerifier"/> grain.
/// This test class is not *necessarily* specific the the <see cref="Demo.Services.PasswordVerifier"/> grain.
/// It is more intended to demonstrate the workings of the "flow" of using the <see cref="ISyncWorker{TRequest, TResult}"/>
/// as far as getting expected results and exceptions from the execution of the grain using the extension method(s)
/// in <see cref="SyncWorkerExtensions"/>.
Expand Down
6 changes: 3 additions & 3 deletions test/Orleans.SyncWork.Tests/SyncWorkerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
using System.Linq;
using System.Threading.Tasks;
using FluentAssertions;
using Orleans.SyncWork.Demo.Api.Services;
using Orleans.SyncWork.Demo.Api.Services.Grains;
using Orleans.SyncWork.Demo.Api.Services.TestGrains;
using Orleans.SyncWork.Demo.Services;
using Orleans.SyncWork.Demo.Services.Grains;
using Orleans.SyncWork.Demo.Services.TestGrains;
using Orleans.SyncWork.Exceptions;
using Orleans.SyncWork.Tests.TestClusters;
using Orleans.SyncWork.Tests.XUnitTraits;
Expand Down
2 changes: 1 addition & 1 deletion test/Orleans.SyncWork.Tests/TestClusters/ClusterFixture.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using Microsoft.Extensions.DependencyInjection;
using Orleans.Hosting;
using Orleans.SyncWork.Demo.Api.Services;
using Orleans.SyncWork.Demo.Services;
using Orleans.TestingHost;

namespace Orleans.SyncWork.Tests.TestClusters;
Expand Down