public static async Task PopulateUsers(IClusterClient client, IUser mark, IUser jack) { await mark.SetName("Mark"); await mark.SetStatus("Share your life with me!"); await jack.SetName("Jack"); await jack.SetStatus("Tweet me!"); await mark.AddFriend(jack); for (int i = 1; i <= 10; i++) { var user = client.GetGrain <IUser>($"user{i}@outlook.com"); await user.SetName($"User #{i}"); await user.SetStatus((i % 3 == 0)? "Sad" : "Happy"); await((i % 2 == 0) ? mark : jack).AddFriend(user); } var tasks = new List <Task>(); for (int j = 101; j <= 20; j++) { var user = client.GetGrain <IUser>($"user{j}@outlook.com"); tasks.Add(user.SetName($"User #{j}")); tasks.Add(user.SetStatus((j % 3 == 0) ? "Sad" : "Happy")); tasks.Add(((j % 2 == 0) ? mark : jack).AddFriend(user)); } await Task.WhenAll(tasks); }
private void AddMutualFriendShipBetweenUsers(IUser user1, IUser user2) { user1.AddFriend(user2); user2.AddFriend(user1); }