This file contains hidden or 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
| static async Task WhenAllWithAsyncAndResultProcessInOneUnitStress() | |
| { | |
| var result = new Result(); | |
| async Task t(int taskId) | |
| { | |
| var r = await APICall(taskId); | |
| result.Result1 = ProcessResult(r, taskId); | |
| } |
This file contains hidden or 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
| static async Task WhenAllWithAsyncAndResultProcessInOneUnit() | |
| { | |
| var result = new Result(); | |
| async Task t1() | |
| { | |
| var r = await APICall1(); | |
| result.Result1 = ProcessResult1(r); | |
| } |
This file contains hidden or 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
| static async Task WhenAllFinishesThenProcess() | |
| { | |
| var response = new Result(); | |
| var t1 = APICall1(); | |
| var t2 = APICall2(); | |
| var t3 = APICall3(); | |
| await Task.WhenAll(t1, t2, t3); |
This file contains hidden or 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
| static async Task ProcessResultOneAtTheTime() | |
| { | |
| var r = new Result(); | |
| var t1 = APICall1(); | |
| var t2 = APICall2(); | |
| var t3 = APICall3(); | |
| r.Result3 = ProcessResult3(await t3); | |
| r.Result2 = ProcessResult2(await t2); |
This file contains hidden or 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
| static async Task ProcessResultOneAtTheTime() | |
| { | |
| var r = new Result(); | |
| var t1 = APICall1(); | |
| var t2 = APICall2(); | |
| var t3 = APICall3(); | |
| r.Result1 = ProcessResult1(await t1); | |
| r.Result2 = ProcessResult2(await t2); |
This file contains hidden or 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
| static Result1Processed ProcessResult1(TaskResult1 r) | |
| { | |
| marker.Measure("Process result 1 start"); | |
| Thread.Sleep(50); | |
| marker.Measure("Process result 1 end"); | |
| return new Result1Processed() { | |
| FinalResult = r.APIResult1 + " processed" |
This file contains hidden or 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
| static async Task<TaskResult1> APICall1() | |
| { | |
| marker.Measure("API call 1 start"); | |
| await Task.Delay(250); | |
| marker.Measure("API call 1 end"); | |
| return new TaskResult1 | |
| { |
This file contains hidden or 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
| // A gateway to all query routes: | |
| public async Task<Data> Query(Guid userId, string queryRoute) | |
| { | |
| var eligibility = await CheckElligibility(userId).ConfigureAwait(false); | |
| if (eligibility != Validity.OK) { | |
| Analytics.LogUserStatus( | |
| queryRoute, | |
| eligibility | |
| ); |
This file contains hidden or 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
| public enum QueryRoute | |
| { | |
| SpiderMan, | |
| Thanos, | |
| IronMan, | |
| CaptainAmerica, | |
| WandaMaximoff, | |
| Thor | |
| } |
This file contains hidden or 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
| [RoutePrefix("users/{userId:Guid}/marvel-characters")] | |
| [JwtAuthorizationFilter(Roles = "Users")] | |
| public class MarvelController : ApiController | |
| { | |
| private readonly IQueryService queryService; | |
| private readonly IMutateService mutateService; | |
| private readonly IPostService postService; | |
| public ApplicationController( | |
| IQueryService getService, |