Skip to content

Commit

Permalink
Introduces separate silo and client projects as a sample
Browse files Browse the repository at this point in the history
* Relates to #60
  • Loading branch information
Kritner committed Oct 21, 2024
1 parent 47bbfe1 commit 61b3751
Show file tree
Hide file tree
Showing 6 changed files with 135 additions and 8 deletions.
16 changes: 10 additions & 6 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,29 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageVersion>
<PackageVersion Include="FluentAssertions" Version="6.2.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Common" Version="4.8.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.8.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Common" Version="4.5.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.5.0" />
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
<PackageVersion Include="Microsoft.Orleans.Server" Version="8.0.0" />
<PackageVersion Include="Microsoft.Orleans.Sdk" Version="8.0.0" />
<PackageVersion Include="Microsoft.Orleans.TestingHost" Version="8.0.0" />
<PackageVersion Include="Microsoft.Orleans.Client" Version="8.2.0" />
<PackageVersion Include="Microsoft.Orleans.Server" Version="8.2.0" />
<PackageVersion Include="Microsoft.Orleans.Sdk" Version="8.2.0" />
<PackageVersion Include="Microsoft.Orleans.TestingHost" Version="8.2.0" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
<PackageVersion Include="Nerdbank.GitVersioning">
<Version>3.4.244</Version>
<PrivateAssets>all</PrivateAssets>
</PackageVersion>
<PackageVersion Include="OrleansDashboard" Version="7.2.2" />
<PackageVersion Include="Swashbuckle.AspNetCore" Version="6.2.3" />
<PackageVersion Include="System.Text.Json" Version="8.0.5" />
<PackageVersion Include="xunit" Version="2.4.1" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageVersion>

</ItemGroup>
</Project>
21 changes: 19 additions & 2 deletions Orleans.SyncWork.sln
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,22 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Orleans.SyncWork", "src\Orl
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{476ED2F0-1D97-425B-B3B7-3AF0961FE4B7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Orleans.SyncWork.Tests", "test\Orleans.SyncWork.Tests\Orleans.SyncWork.Tests.csproj", "{45FA9797-D1D9-4DC6-8456-D9B8A9C52102}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "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}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Orleans.SyncWork.Demo.Services", "samples\Orleans.SyncWork.Demo.Services\Orleans.SyncWork.Demo.Services.csproj", "{961EF604-582A-461C-90CE-C7FFE6C40769}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Misc", "Misc", "{8CC7CA68-C6E7-486A-B972-705CC8A05031}"
ProjectSection(SolutionItems) = preProject
Directory.Build.props = Directory.Build.props
Directory.Packages.props = Directory.Packages.props
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SeparateSiloAndClient", "SeparateSiloAndClient", "{A6D5590F-689D-4851-9DC4-9C0553233265}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Silo", "samples\SeparateSiloAndClient\Silo\Silo.csproj", "{E4CDE27D-0DEC-4068-B7B0-0F5DBC9D218B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Client", "samples\SeparateSiloAndClient\Client\Client.csproj", "{24E1284B-92C9-4D05-A7A6-C406883BC5FA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -51,6 +57,14 @@ Global
{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
{E4CDE27D-0DEC-4068-B7B0-0F5DBC9D218B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E4CDE27D-0DEC-4068-B7B0-0F5DBC9D218B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E4CDE27D-0DEC-4068-B7B0-0F5DBC9D218B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E4CDE27D-0DEC-4068-B7B0-0F5DBC9D218B}.Release|Any CPU.Build.0 = Release|Any CPU
{24E1284B-92C9-4D05-A7A6-C406883BC5FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{24E1284B-92C9-4D05-A7A6-C406883BC5FA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{24E1284B-92C9-4D05-A7A6-C406883BC5FA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{24E1284B-92C9-4D05-A7A6-C406883BC5FA}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -61,6 +75,9 @@ Global
{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}
{A6D5590F-689D-4851-9DC4-9C0553233265} = {20B3ED9E-B5FB-47A8-B24E-9EED821AEBE3}
{E4CDE27D-0DEC-4068-B7B0-0F5DBC9D218B} = {A6D5590F-689D-4851-9DC4-9C0553233265}
{24E1284B-92C9-4D05-A7A6-C406883BC5FA} = {A6D5590F-689D-4851-9DC4-9C0553233265}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {17BB45B7-AC08-488D-905F-11E706140C72}
Expand Down
21 changes: 21 additions & 0 deletions samples/SeparateSiloAndClient/Client/Client.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" />
<PackageReference Include="Microsoft.Orleans.Client" />
</ItemGroup>

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

</Project>
39 changes: 39 additions & 0 deletions samples/SeparateSiloAndClient/Client/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Hosting;
using Orleans.SyncWork.Demo.Services.Grains;
using Orleans.SyncWork;

Console.WriteLine("Hello, World!");

IHostBuilder builder = Host.CreateDefaultBuilder(args)
.UseOrleansClient(client =>
{
client.UseLocalhostClustering();
})
.ConfigureLogging(logging => logging.AddConsole())
.UseConsoleLifetime();

using IHost host = builder.Build();
await host.StartAsync();

IClusterClient client = host.Services.GetRequiredService<IClusterClient>();

IPasswordVerifierGrain grain = client.GetGrain<IPasswordVerifierGrain>(Guid.NewGuid());

var result = await grain.StartWorkAndPollUntilResult(
new PasswordVerifierRequest()
{
Password = "my super neat password that's totally secure because it's super long",
PasswordHash = "$2a$11$vBzJ4Ewx28C127AG5x3kT.QCCS8ai0l4JLX3VOX3MzHRkF4/A5twy"
});

Console.WriteLine($"""
IsValid password: {result.IsValid}
Press any key to exit...
""");

Console.ReadKey();

await host.StopAsync();
24 changes: 24 additions & 0 deletions samples/SeparateSiloAndClient/Silo/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Orleans.SyncWork.Demo.Services;
using Orleans.SyncWork.ExtensionMethods;

Console.WriteLine("Hello, World!");

IHostBuilder builder = Host.CreateDefaultBuilder(args)
.UseOrleans(silo =>
{
silo.UseLocalhostClustering()
.ConfigureLogging(logging => logging.AddConsole());
silo.ConfigureSyncWorkAbstraction(2);
})
.UseConsoleLifetime()
.ConfigureServices(collection =>
{
collection.AddSingleton<IPasswordVerifier, PasswordVerifier>();
});

using IHost host = builder.Build();

await host.RunAsync();
22 changes: 22 additions & 0 deletions samples/SeparateSiloAndClient/Silo/Silo.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" />
<PackageReference Include="Microsoft.Orleans.Server" />
</ItemGroup>

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

</Project>

0 comments on commit 61b3751

Please sign in to comment.