From 61b3751fd55fba863246f8f35dcb4371623c3ca8 Mon Sep 17 00:00:00 2001 From: Russ Hammett Date: Mon, 21 Oct 2024 07:50:02 -0400 Subject: [PATCH] Introduces separate silo and client projects as a sample * Relates to #60 --- Directory.Packages.props | 16 +++++--- Orleans.SyncWork.sln | 21 +++++++++- .../Client/Client.csproj | 21 ++++++++++ .../SeparateSiloAndClient/Client/Program.cs | 39 +++++++++++++++++++ samples/SeparateSiloAndClient/Silo/Program.cs | 24 ++++++++++++ .../SeparateSiloAndClient/Silo/Silo.csproj | 22 +++++++++++ 6 files changed, 135 insertions(+), 8 deletions(-) create mode 100644 samples/SeparateSiloAndClient/Client/Client.csproj create mode 100644 samples/SeparateSiloAndClient/Client/Program.cs create mode 100644 samples/SeparateSiloAndClient/Silo/Program.cs create mode 100644 samples/SeparateSiloAndClient/Silo/Silo.csproj diff --git a/Directory.Packages.props b/Directory.Packages.props index 9c1fbc1..34f9e90 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -11,13 +11,17 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - - + + + + + - - - + + + + 3.4.244 @@ -25,11 +29,11 @@ + runtime; build; native; contentfiles; analyzers; buildtransitive all - \ No newline at end of file diff --git a/Orleans.SyncWork.sln b/Orleans.SyncWork.sln index 7240b73..8ec8ce5 100644 --- a/Orleans.SyncWork.sln +++ b/Orleans.SyncWork.sln @@ -15,9 +15,9 @@ 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 @@ -25,6 +25,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Misc", "Misc", "{8CC7CA68-C 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 @@ -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 @@ -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} diff --git a/samples/SeparateSiloAndClient/Client/Client.csproj b/samples/SeparateSiloAndClient/Client/Client.csproj new file mode 100644 index 0000000..be90a34 --- /dev/null +++ b/samples/SeparateSiloAndClient/Client/Client.csproj @@ -0,0 +1,21 @@ + + + + Exe + net8.0 + enable + enable + + + + + + + + + + + + + + diff --git a/samples/SeparateSiloAndClient/Client/Program.cs b/samples/SeparateSiloAndClient/Client/Program.cs new file mode 100644 index 0000000..3e82c3e --- /dev/null +++ b/samples/SeparateSiloAndClient/Client/Program.cs @@ -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(); + +IPasswordVerifierGrain grain = client.GetGrain(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(); diff --git a/samples/SeparateSiloAndClient/Silo/Program.cs b/samples/SeparateSiloAndClient/Silo/Program.cs new file mode 100644 index 0000000..0678899 --- /dev/null +++ b/samples/SeparateSiloAndClient/Silo/Program.cs @@ -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(); + }); + +using IHost host = builder.Build(); + +await host.RunAsync(); diff --git a/samples/SeparateSiloAndClient/Silo/Silo.csproj b/samples/SeparateSiloAndClient/Silo/Silo.csproj new file mode 100644 index 0000000..62f0397 --- /dev/null +++ b/samples/SeparateSiloAndClient/Silo/Silo.csproj @@ -0,0 +1,22 @@ + + + + Exe + net8.0 + enable + enable + + + + + + + + + + + + + + +