public async Task <IActionResult> RunTasks([FromBody] LookUpRequest request)
        {
            try
            {
                _logger.LogInformation(
                    $"New Request with {request.Services?.Count ?? 0} selected services for {request.Address}");
                var badReq = CheckModelState(request);
                if (badReq != null)
                {
                    return(badReq);
                }

                var services = SetDefaultServicesIfNull(request.Services);

                var res = await WorkerHelper
                          .SendToWorkers(_config["WORKER_ADDRESS"], request.Address, services);

                _logger.LogInformation($"Finished processing request for {request.Address}");
                return(new OkObjectResult(res));
            }
            catch (Exception e)
            {
                _logger.LogError(e, $"Error processing request for {request.Address}");
                return(StatusCode(StatusCodes.Status500InternalServerError, new AppErrorResult
                {
                    ErrorMessage = $"Unexpected Error: {e}",
                    FailServices = SetDefaultServicesIfNull(request.Services)
                }));
            }
        }
예제 #2
0
        public async Task should_set_item_with_bad_result()
        {
            var actual = await WorkerHelper.SendToWorkers("", "", new List <ServiceType>()
            {
                ServiceType.GeoIP
            });

            Assert.IsNotNull(actual.GeoIp.ErrorMessage);
            Assert.AreEqual(ServiceStatus.Error, actual.GeoIp.Status);
        }