コード例 #1
0
ファイル: HttpApi.cs プロジェクト: exactly-once/workshop
        public async Task <IActionResult> FireAt(
            [HttpTrigger(AuthorizationLevel.Anonymous, "post")] FireAtRequest request,
            [ExactlyOnce("{requestId}")] IOnceExecutor execute,
            [Queue("fire-at")] ICollector <FireAt> collector,
            ILogger log)
        {
            log.LogWarning($"Processing FireAt: requestId={request.RequestId}");

            var fireAt = await execute.Once(
                () => new FireAt
            {
                AttemptId = request.RequestId.ToGuid(),
                GameId    = request.GameId.ToGuid(),
                Position  = request.Position
            }
                );

            collector.Add(fireAt);

            return(new AcceptedResult());
        }
コード例 #2
0
        public async Task <IActionResult> RequestFireAt(
            [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)]
            FireAtRequest request,
            [ExactlyOnce("{RequestId}")] IOnceExecutor execute,
            [Queue("fire-attempt")] ICollector <FireAt> collector,
            ILogger log)
        {
            log.LogInformation($"Processing RequestFireAt: requestId={request.RequestId}");

            //HINT: any duplicated executions will return FireAt identical to the first execution
            var fireAt = await execute.Once(
                () => new FireAt
            {
                AttemptId = request.RequestId.ToGuid(),
                GameId    = request.GameId.ToGuid(),
                Position  = request.Position
            }
                );

            collector.Add(fireAt);

            return(new OkObjectResult("New round requested."));
        }