Browse Source

Merge pull request #320 from SychevIgor/SychevIgor/PaymntHealthCheck

payment API require health check
pull/816/head
Cesar De la Torre 7 years ago
committed by GitHub
parent
commit
79d045f897
7 changed files with 11 additions and 46 deletions
  1. +1
    -0
      docker-compose.override.yml
  2. +0
    -19
      src/Services/Payment/Payment.API/Controllers/HomeController.cs
  3. +0
    -4
      src/Services/Payment/Payment.API/Payment.API.csproj
  4. +1
    -1
      src/Services/Payment/Payment.API/Program.cs
  5. +6
    -21
      src/Services/Payment/Payment.API/Startup.cs
  6. +1
    -0
      src/Web/WebStatus/Startup.cs
  7. +2
    -1
      src/Web/WebStatus/appsettings.json

+ 1
- 0
docker-compose.override.yml View File

@ -136,6 +136,7 @@ services:
- IdentityUrl=http://identity.api/hc
- LocationsUrl=http://locations.api/hc
- MarketingUrl=http://marketing.api/hc
- PaymentUrl=http://payment.api/hc
- mvc=http://webmvc/hc
- spa=http://webspa/hc
ports:


+ 0
- 19
src/Services/Payment/Payment.API/Controllers/HomeController.cs View File

@ -1,19 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
// For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
namespace Payment.API.Controllers
{
public class HomeController : Controller
{
// GET: /<controller>/
public IActionResult Index()
{
return new RedirectResult("~/swagger");
}
}
}

+ 0
- 4
src/Services/Payment/Payment.API/Payment.API.csproj View File

@ -6,13 +6,9 @@
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>
</PropertyGroup>
<ItemGroup>
<Folder Include="wwwroot\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="4.1.0" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="1.0.0" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />


+ 1
- 1
src/Services/Payment/Payment.API/Program.cs View File

@ -15,7 +15,7 @@ namespace Payment.API
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseHealthChecks("/hc")
.UseContentRoot(Directory.GetCurrentDirectory())
.UseStartup<Startup>()
.ConfigureLogging((hostingContext, builder) =>


+ 6
- 21
src/Services/Payment/Payment.API/Startup.cs View File

@ -9,11 +9,13 @@ using Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ;
using Microsoft.eShopOnContainers.BuildingBlocks.EventBusServiceBus;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.HealthChecks;
using Microsoft.Extensions.Logging;
using Payment.API.IntegrationEvents.EventHandling;
using Payment.API.IntegrationEvents.Events;
using RabbitMQ.Client;
using System;
using System.Threading.Tasks;
namespace Payment.API
{
@ -29,8 +31,6 @@ namespace Payment.API
// This method gets called by the runtime. Use this method to add services to the container.
public IServiceProvider ConfigureServices(IServiceCollection services)
{
// Add framework services.
services.AddMvc();
services.Configure<PaymentSettings>(Configuration);
@ -70,20 +70,13 @@ namespace Payment.API
});
}
RegisterEventBus(services);
services.AddSwaggerGen(options =>
services.AddHealthChecks(checks =>
{
options.DescribeAllEnumsAsStrings();
options.SwaggerDoc("v1", new Swashbuckle.AspNetCore.Swagger.Info
{
Title = "eShopOnContainers - Payment HTTP API",
Version = "v1",
Description = "The Payment Microservice HTTP API. This is a Data-Driven/CRUD microservice sample",
TermsOfService = "Terms Of Service"
});
checks.AddValueTaskCheck("HTTP Endpoint", () => new ValueTask<IHealthCheckResult>(HealthCheckResult.Healthy("Ok")));
});
RegisterEventBus(services);
var container = new ContainerBuilder();
container.Populate(services);
return new AutofacServiceProvider(container.Build());
@ -98,14 +91,6 @@ namespace Payment.API
app.UsePathBase(pathBase);
}
app.UseMvcWithDefaultRoute();
app.UseSwagger()
.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
});
ConfigureEventBus(app);
}


+ 1
- 0
src/Web/WebStatus/Startup.cs View File

@ -40,6 +40,7 @@ namespace WebStatus
checks.AddUrlCheckIfNotNull(Configuration["IdentityUrl"], TimeSpan.FromMinutes(minutes));
checks.AddUrlCheckIfNotNull(Configuration["LocationsUrl"], TimeSpan.FromMinutes(minutes));
checks.AddUrlCheckIfNotNull(Configuration["MarketingUrl"], TimeSpan.FromMinutes(minutes));
checks.AddUrlCheckIfNotNull(Configuration["PaymentUrl"], TimeSpan.FromMinutes(minutes));
checks.AddUrlCheckIfNotNull(Configuration["mvc"], TimeSpan.FromMinutes(minutes));
checks.AddUrlCheckIfNotNull(Configuration["spa"], TimeSpan.FromMinutes(minutes));
});


+ 2
- 1
src/Web/WebStatus/appsettings.json View File

@ -10,5 +10,6 @@
"CatalogUrl": "http://localhost:5101/hc",
"IdentityUrl": "http://localhost:5105/hc",
"MarketingUrl": "http://localhost:5110/hc",
"LocationsUrl": "http://localhost:5109/hc"
"LocationsUrl": "http://localhost:5109/hc",
"PaymentUrl": "http://localhost:5108/hc"
}

Loading…
Cancel
Save