Skip to content

Commit

Permalink
#27 use beatpulse instead of built it from scratch as now
Browse files Browse the repository at this point in the history
  • Loading branch information
thangchung committed Dec 7, 2018
1 parent cd9a59d commit 5b5d695
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 113 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -334,3 +334,4 @@ tools
build
*.deb
**/*/*.db
**/*/livenessdb
3 changes: 3 additions & 0 deletions samples/BiMonetaryApi/NetCoreKit.Samples.BiMonetaryApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BeatPulse" Version="3.0.0" />
<PackageReference Include="BeatPulse.MongoDb" Version="3.0.0" />
<PackageReference Include="BeatPulse.UI" Version="3.0.1" />
<PackageReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

Expand Down
7 changes: 0 additions & 7 deletions samples/BiMonetaryApi/Program.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;

namespace NetCoreKit.Samples.BiMonetaryApi
{
Expand Down
16 changes: 14 additions & 2 deletions samples/BiMonetaryApi/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using BeatPulse.UI;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using NetCoreKit.Infrastructure.AspNetCore.Miniservice;
Expand All @@ -8,12 +9,23 @@ public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddMongoMiniService();
services
.AddMongoMiniService()
.AddBeatPulse()
.AddBeatPulseUI();
}

public void Configure(IApplicationBuilder app)
{
app.UseMiniService();
app
.UseBeatPulse(options =>
{
options.ConfigurePath(path: "healthz") //default hc
.ConfigureTimeout(milliseconds: 1500) // default -1 infinitely
.ConfigureDetailedOutput(detailedOutput: true, includeExceptionMessages: true); //default (true,false)
})
.UseBeatPulseUI()
.UseMiniService();
}
}
}
11 changes: 11 additions & 0 deletions samples/BiMonetaryApi/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@
"Audience": "api"
}
},
"BeatPulse-UI": {
"Liveness": [
{
"Name": "BiMonetaryApi",
"Uri": "http://localhost:54408/healthz"
}
],
"Webhooks": [
],
"EvaluationTimeOnSeconds": 10
},
"Logging": {
"LogLevel": {
"Default": "Warning"
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ namespace NetCoreKit.Infrastructure.AspNetCore.Miniservice
{
public static partial class ServiceCollectionExtensions
{
public static IServiceCollection AddEfCoreMiniService<TDbContext>(
this IServiceCollection services,
public static IServiceCollection AddEfCoreMiniService<TDbContext>(this IServiceCollection services,
Action<IServiceCollection> preDbWorkHook = null,
Action<IServiceCollection, IServiceProvider> postDbWorkHook = null)
where TDbContext : DbContext
Expand All @@ -30,10 +29,8 @@ public static partial class ServiceCollectionExtensions
var env = svcProvider.GetRequiredService<IHostingEnvironment>();
var feature = svcProvider.GetRequiredService<IFeature>();

// let registering the database providers or others from the outside
preDbWorkHook?.Invoke(services);

// #1
if (feature.IsEnabled("EfCore"))
{
if (feature.IsEnabled("Mongo")) throw new Exception("Please turn off MongoDb settings.");
Expand All @@ -50,43 +47,32 @@ public static partial class ServiceCollectionExtensions
services.AddGenericRepository();
}

// let outside inject more logic (like more healthcheck endpoints...)
postDbWorkHook?.Invoke(services, svcProvider);

// RestClient out of the box
services.AddRestClientCore();

// DomainEventBus for handling the published event from the domain object
services.AddSingleton<IDomainEventBus, MemoryDomainEventBus>();

// #3
if (feature.IsEnabled("CleanArch"))
services.AddCleanArch(config.LoadFullAssemblies());

services.AddCacheCore();

// #4
if (feature.IsEnabled("ApiVersion"))
services.AddApiVersionCore(config);

// #5
services.AddMvcCore(config);

// #6
services.AddDetailExceptionCore();

// #7
if (feature.IsEnabled("AuthN"))
services.AddAuthNCore(config, env);

// #8
if (feature.IsEnabled("OpenApi"))
services.AddOpenApiCore(config, feature);

// #9
services.AddCorsCore();

// #10
services.AddHeaderForwardCore(env);

if (feature.IsEnabled("OpenApi:Profiler"))
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ namespace NetCoreKit.Infrastructure.AspNetCore.Miniservice
{
public static partial class ServiceCollectionExtensions
{
public static IServiceCollection AddMongoMiniService(
this IServiceCollection services,
public static IServiceCollection AddMongoMiniService(this IServiceCollection services,
Action<IServiceCollection> preDbWorkHook = null,
Action<IServiceCollection, IServiceProvider> postDbWorkHook = null)
{
Expand All @@ -26,54 +25,41 @@ public static partial class ServiceCollectionExtensions
var env = svcProvider.GetRequiredService<IHostingEnvironment>();
var feature = svcProvider.GetRequiredService<IFeature>();

// let registering the database providers or others from the outside
preDbWorkHook?.Invoke(services);

// #1
if (feature.IsEnabled("Mongo"))
{
if (feature.IsEnabled("EfCore"))
throw new Exception("Please turn off EfCore settings.");
services.AddMongoDb();
}

// let outside inject more logic (like more healthcheck endpoints...)
postDbWorkHook?.Invoke(services, svcProvider);

// RestClient out of the box
services.AddRestClientCore();

// DomainEventBus for handling the published event from the domain object
services.AddSingleton<IDomainEventBus, MemoryDomainEventBus>();

// #3
if (feature.IsEnabled("CleanArch"))
services.AddCleanArch(config.LoadFullAssemblies());

services.AddCacheCore();

// #4
if (feature.IsEnabled("ApiVersion"))
services.AddApiVersionCore(config);

// #5
services.AddMvcCore(config);

// #6
services.AddDetailExceptionCore();

// #7
if (feature.IsEnabled("AuthN"))
services.AddAuthNCore(config, env);

// #8
if (feature.IsEnabled("OpenApi"))
services.AddOpenApiCore(config, feature);

// #9
services.AddCorsCore();

// #10
services.AddHeaderForwardCore(env);

if (feature.IsEnabled("OpenApi:Profiler"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ namespace NetCoreKit.Infrastructure.AspNetCore.Miniservice
{
public static partial class ServiceCollectionExtensions
{
public static IServiceCollection AddMiniService(
this IServiceCollection services,
public static IServiceCollection AddMiniService(this IServiceCollection services,
Action<IServiceCollection, IServiceProvider> preHook = null)
{
services.AddFeatureToggle();
Expand All @@ -24,43 +23,32 @@ public static partial class ServiceCollectionExtensions
var env = svcProvider.GetRequiredService<IHostingEnvironment>();
var feature = svcProvider.GetRequiredService<IFeature>();

// let registering the database providers or others from the outside
preHook?.Invoke(services, svcProvider);

// RestClient out of the box
services.AddRestClientCore();

// DomainEventBus for handling the published event from the domain object
services.AddSingleton<IDomainEventBus, MemoryDomainEventBus>();

// #3
if (feature.IsEnabled("CleanArch"))
services.AddCleanArch(config.LoadFullAssemblies());

services.AddCacheCore();

// #4
if (feature.IsEnabled("ApiVersion"))
services.AddApiVersionCore(config);

// #5
services.AddMvcCore(config);

// #6
services.AddDetailExceptionCore();

// #7
if (feature.IsEnabled("AuthN"))
services.AddAuthNCore(config, env);

// #8
if (feature.IsEnabled("OpenApi"))
services.AddOpenApiCore(config, feature);

// #9
services.AddCorsCore();

// #10
services.AddHeaderForwardCore(env);

if (feature.IsEnabled("OpenApi:Profiler"))
Expand Down

0 comments on commit 5b5d695

Please sign in to comment.