-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ private static async Task<int> 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<IVisitTracker>("[email protected]"); | ||
var notKritnerGrain = client.GetGrain<IVisitTracker>("[email protected]"); | ||
|
||
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}"); | ||
} | ||
} | ||
} |