diff --git a/src/Kritner.OrleansGettingStarted.Client/Program.cs b/src/Kritner.OrleansGettingStarted.Client/Program.cs index 9c2a13b..631a8b0 100644 --- a/src/Kritner.OrleansGettingStarted.Client/Program.cs +++ b/src/Kritner.OrleansGettingStarted.Client/Program.cs @@ -25,6 +25,7 @@ private static async Task RunMainAsync() using (var client = await StartClientWithRetries()) { await DoClientWork(client); + await DoStatefulWork(client); Console.ReadKey(); } @@ -85,6 +86,52 @@ private static async Task DoClientWork(IClusterClient client) Console.WriteLine($"{await grain.SayHello("1")}"); Console.WriteLine($"{await grain2.SayHello("2")}"); Console.WriteLine($"{await grain.SayHello("3")}"); + + PrintSeparatorThing(); + } + + private static async Task DoStatefulWork(IClusterClient client) + { + var kritnerGrain = client.GetGrain("kritner@gmail.com"); + var notKritnerGrain = client.GetGrain("notKritner@gmail.com"); + + await PrettyPrintGrainVisits(kritnerGrain); + await PrettyPrintGrainVisits(notKritnerGrain); + + PrintSeparatorThing(); + Console.WriteLine("Ayyy some people are visiting!"); + + await kritnerGrain.Visit(); + await kritnerGrain.Visit(); + await notKritnerGrain.Visit(); + + PrintSeparatorThing(); + + await PrettyPrintGrainVisits(kritnerGrain); + await PrettyPrintGrainVisits(notKritnerGrain); + + PrintSeparatorThing(); + Console.Write("ayyy kritner's visiting even more!"); + + for (int i = 0; i < 5; i++) + { + await kritnerGrain.Visit(); + } + + PrintSeparatorThing(); + + await PrettyPrintGrainVisits(kritnerGrain); + await PrettyPrintGrainVisits(notKritnerGrain); + } + + private static async Task PrettyPrintGrainVisits(IVisitTracker grain) + { + Console.WriteLine($"{grain.GetPrimaryKeyString()} has visited {await grain.GetNumberOfVisits()} times"); + } + + private static void PrintSeparatorThing() + { + Console.WriteLine($"{Environment.NewLine}-----{Environment.NewLine}"); } } }