public async Task IncrementCommitment(IClusterClient client, int partitionNumber, int iteration) { var agent = client.GetVertexGrain <IAgent>(Guid.NewGuid(), "agents"); var resource = client.GetVertexGrain <IResource>(Guid.NewGuid(), "resources"); var incrementEvent = client.GetVertexGrain <IIncrementCommitment>(Guid.NewGuid(), "events"); await incrementEvent.Initialize(agent, resource, 20); Console.WriteLine(" ==> IIncrementCommitment.Initialize(agent, resource, 20)"); }
public async Task Profile(IClusterClient client, int partitionNumber, int iteration) { try { Stopwatch stopwatch = Stopwatch.StartNew(); var primaryKey = Guid.NewGuid(); IPerson person = client.GetVertexGrain <IPerson>(primaryKey, "partition" + partitionNumber); stopwatch.Restart(); await person.SetPersonalDataAsync(new PersonalData($"Person{iteration}FirstName", $"Person{iteration}LastName") { Birthdate = DateTime.Parse("10/02/1982") }); Console.WriteLine($" ==> SetPersonalDataAsync: {stopwatch.ElapsedMilliseconds}ms"); stopwatch.Restart(); IProfile personalProfile = await person.AddProfileAsync(new ProfileData { Name = "PersonalProfile" }); Console.WriteLine($" ==> Add Personal Profile: {stopwatch.ElapsedMilliseconds}ms"); stopwatch.Restart(); IProfile businessProfile = await person.AddProfileAsync(new ProfileData { Name = "BusinessProfile" }); Console.WriteLine($" ==> Add Business Profile: {stopwatch.ElapsedMilliseconds}ms"); Console.WriteLine(); stopwatch.Restart(); person = client.GetVertexGrain <IPerson>(primaryKey, "partition" + partitionNumber); var personalDataAsync = await person.GetPersonalDataAsync(); ProfileData personalProfileData = await personalProfile.GetProfileDataAsync(); Console.WriteLine($" ==> Get Personal Profile: {stopwatch.ElapsedMilliseconds}ms"); stopwatch.Restart(); ProfileData businessProfileData = await businessProfile.GetProfileDataAsync(); Console.WriteLine($" ==> Get Business Profile: {stopwatch.ElapsedMilliseconds}ms"); stopwatch.Stop(); Console.WriteLine(); } catch (Exception ex) { Console.WriteLine(); Console.WriteLine($"==> Caught excpetion {ex.Message}"); Console.WriteLine(); throw; } }
public async Task <ActionResult <PersonalData> > GetPerson(Guid id) { var person = clusterClient.GetVertexGrain <IPerson>(id, "partition0"); return(Ok(await person.GetPersonalDataAsync())); }