public async Task <AttemptMade> ProcessFireAt([QueueTrigger("fire-attempt", Connection = "AzureWebJobsStorage")]
                                                      FireAt fireAt,
                                                      ILogger log)
        {
            log.LogInformation($"Processed startRound: gameId={fireAt.GameId}, position={fireAt.Position}");

            var(message, blob) = await execute
                                 .Once <FireAt>(fireAt.AttemptId)
                                 .On <ShootingRangeState>(fireAt.GameId)
                                 .WithOutput(sr =>
            {
                var attemptMade = new AttemptMade
                {
                    AttemptId = fireAt.AttemptId,
                    GameId    = fireAt.GameId
                };

                if (sr.TargetPosition == fireAt.Position)
                {
                    attemptMade.IsHit = true;
                }
                else
                {
                    attemptMade.IsHit = false;
                }

                return(attemptMade, new BlobInfo {
                    BlobName = "This also a side effect"
                });
            });


            return(message);
        }
Exemplo n.º 2
0
        public async Task <AttemptMade> ProcessFireAt(
            [QueueTrigger("fire-attempt")] FireAt fireAt,
            [ExactlyOnce(requestId: "{attemptId}", stateId: "{gameId}")] IOnceExecutor <ShootingRangeState> execute,
            ILogger log)
        {
            log.LogInformation($"Processed startRound: gameId={fireAt.GameId}, position={fireAt.Position}");

            var(message, blob) = await execute.Once(sr =>
            {
                var attemptMade = new AttemptMade
                {
                    AttemptId = fireAt.AttemptId,
                    GameId    = fireAt.GameId
                };

                if (sr.TargetPosition == fireAt.Position)
                {
                    attemptMade.IsHit = true;
                }
                else
                {
                    attemptMade.IsHit = false;
                }

                return(attemptMade, new BlobInfo {
                    BlobName = "This also a side effect"
                });
            });

            return(message);
        }
Exemplo n.º 3
0
        public async Task <AttemptMade> HandleFireAt(
            [QueueTrigger("fire-at")] FireAt fireAt,
            [ExactlyOnce("{attemptId}", "{gameId}")]
            IOnceExecutor <ShootingRangeState> execute,
            ILogger log)
        {
            var timestamp = await ExecuteHttpRequest();

            var message = await execute.Once(sr =>
            {
                if (sr.IsActive == false)
                {
                    return(default);