Skip to content

Commit 5b5d695

Browse files
committed
#27 use beatpulse instead of built it from scratch as now
1 parent cd9a59d commit 5b5d695

File tree

10 files changed

+32
-113
lines changed

10 files changed

+32
-113
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,3 +334,4 @@ tools
334334
build
335335
*.deb
336336
**/*/*.db
337+
**/*/livenessdb

samples/BiMonetaryApi/NetCoreKit.Samples.BiMonetaryApi.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9+
<PackageReference Include="BeatPulse" Version="3.0.0" />
10+
<PackageReference Include="BeatPulse.MongoDb" Version="3.0.0" />
11+
<PackageReference Include="BeatPulse.UI" Version="3.0.1" />
912
<PackageReference Include="Microsoft.AspNetCore.App" />
1013
</ItemGroup>
1114

samples/BiMonetaryApi/Program.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.IO;
4-
using System.Linq;
5-
using System.Threading.Tasks;
61
using Microsoft.AspNetCore;
72
using Microsoft.AspNetCore.Hosting;
8-
using Microsoft.Extensions.Configuration;
9-
using Microsoft.Extensions.Logging;
103

114
namespace NetCoreKit.Samples.BiMonetaryApi
125
{

samples/BiMonetaryApi/Startup.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using BeatPulse.UI;
12
using Microsoft.AspNetCore.Builder;
23
using Microsoft.Extensions.DependencyInjection;
34
using NetCoreKit.Infrastructure.AspNetCore.Miniservice;
@@ -8,12 +9,23 @@ public class Startup
89
{
910
public void ConfigureServices(IServiceCollection services)
1011
{
11-
services.AddMongoMiniService();
12+
services
13+
.AddMongoMiniService()
14+
.AddBeatPulse()
15+
.AddBeatPulseUI();
1216
}
1317

1418
public void Configure(IApplicationBuilder app)
1519
{
16-
app.UseMiniService();
20+
app
21+
.UseBeatPulse(options =>
22+
{
23+
options.ConfigurePath(path: "healthz") //default hc
24+
.ConfigureTimeout(milliseconds: 1500) // default -1 infinitely
25+
.ConfigureDetailedOutput(detailedOutput: true, includeExceptionMessages: true); //default (true,false)
26+
})
27+
.UseBeatPulseUI()
28+
.UseMiniService();
1729
}
1830
}
1931
}

samples/BiMonetaryApi/appsettings.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,17 @@
4141
"Audience": "api"
4242
}
4343
},
44+
"BeatPulse-UI": {
45+
"Liveness": [
46+
{
47+
"Name": "BiMonetaryApi",
48+
"Uri": "http://localhost:54408/healthz"
49+
}
50+
],
51+
"Webhooks": [
52+
],
53+
"EvaluationTimeOnSeconds": 10
54+
},
4455
"Logging": {
4556
"LogLevel": {
4657
"Default": "Warning"

src/NetCoreKit.Infrastructure.AspNetCore.Miniservice/Controllers/HealthController.cs

Lines changed: 0 additions & 40 deletions
This file was deleted.

src/NetCoreKit.Infrastructure.AspNetCore.Miniservice/EfCore.ServiceCollectionExtensions.cs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ namespace NetCoreKit.Infrastructure.AspNetCore.Miniservice
1515
{
1616
public static partial class ServiceCollectionExtensions
1717
{
18-
public static IServiceCollection AddEfCoreMiniService<TDbContext>(
19-
this IServiceCollection services,
18+
public static IServiceCollection AddEfCoreMiniService<TDbContext>(this IServiceCollection services,
2019
Action<IServiceCollection> preDbWorkHook = null,
2120
Action<IServiceCollection, IServiceProvider> postDbWorkHook = null)
2221
where TDbContext : DbContext
@@ -30,10 +29,8 @@ public static IServiceCollection AddEfCoreMiniService<TDbContext>(
3029
var env = svcProvider.GetRequiredService<IHostingEnvironment>();
3130
var feature = svcProvider.GetRequiredService<IFeature>();
3231

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

36-
// #1
3734
if (feature.IsEnabled("EfCore"))
3835
{
3936
if (feature.IsEnabled("Mongo")) throw new Exception("Please turn off MongoDb settings.");
@@ -50,43 +47,32 @@ public static IServiceCollection AddEfCoreMiniService<TDbContext>(
5047
services.AddGenericRepository();
5148
}
5249

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

56-
// RestClient out of the box
5752
services.AddRestClientCore();
5853

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

62-
// #3
6356
if (feature.IsEnabled("CleanArch"))
6457
services.AddCleanArch(config.LoadFullAssemblies());
6558

6659
services.AddCacheCore();
6760

68-
// #4
6961
if (feature.IsEnabled("ApiVersion"))
7062
services.AddApiVersionCore(config);
7163

72-
// #5
7364
services.AddMvcCore(config);
7465

75-
// #6
7666
services.AddDetailExceptionCore();
7767

78-
// #7
7968
if (feature.IsEnabled("AuthN"))
8069
services.AddAuthNCore(config, env);
8170

82-
// #8
8371
if (feature.IsEnabled("OpenApi"))
8472
services.AddOpenApiCore(config, feature);
8573

86-
// #9
8774
services.AddCorsCore();
8875

89-
// #10
9076
services.AddHeaderForwardCore(env);
9177

9278
if (feature.IsEnabled("OpenApi:Profiler"))

src/NetCoreKit.Infrastructure.AspNetCore.Miniservice/ExternalSystems/DbHealthCheckAndMigration.cs

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/NetCoreKit.Infrastructure.AspNetCore.Miniservice/Mongo.ServiceCollectionExtensions.cs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ namespace NetCoreKit.Infrastructure.AspNetCore.Miniservice
1212
{
1313
public static partial class ServiceCollectionExtensions
1414
{
15-
public static IServiceCollection AddMongoMiniService(
16-
this IServiceCollection services,
15+
public static IServiceCollection AddMongoMiniService(this IServiceCollection services,
1716
Action<IServiceCollection> preDbWorkHook = null,
1817
Action<IServiceCollection, IServiceProvider> postDbWorkHook = null)
1918
{
@@ -26,54 +25,41 @@ public static IServiceCollection AddMongoMiniService(
2625
var env = svcProvider.GetRequiredService<IHostingEnvironment>();
2726
var feature = svcProvider.GetRequiredService<IFeature>();
2827

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

32-
// #1
3330
if (feature.IsEnabled("Mongo"))
3431
{
3532
if (feature.IsEnabled("EfCore"))
3633
throw new Exception("Please turn off EfCore settings.");
3734
services.AddMongoDb();
3835
}
3936

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

43-
// RestClient out of the box
4439
services.AddRestClientCore();
4540

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

49-
// #3
5043
if (feature.IsEnabled("CleanArch"))
5144
services.AddCleanArch(config.LoadFullAssemblies());
5245

5346
services.AddCacheCore();
5447

55-
// #4
5648
if (feature.IsEnabled("ApiVersion"))
5749
services.AddApiVersionCore(config);
5850

59-
// #5
6051
services.AddMvcCore(config);
6152

62-
// #6
6353
services.AddDetailExceptionCore();
6454

65-
// #7
6655
if (feature.IsEnabled("AuthN"))
6756
services.AddAuthNCore(config, env);
6857

69-
// #8
7058
if (feature.IsEnabled("OpenApi"))
7159
services.AddOpenApiCore(config, feature);
7260

73-
// #9
7461
services.AddCorsCore();
7562

76-
// #10
7763
services.AddHeaderForwardCore(env);
7864

7965
if (feature.IsEnabled("OpenApi:Profiler"))

src/NetCoreKit.Infrastructure.AspNetCore.Miniservice/ServiceCollectionExtensions.cs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ namespace NetCoreKit.Infrastructure.AspNetCore.Miniservice
1111
{
1212
public static partial class ServiceCollectionExtensions
1313
{
14-
public static IServiceCollection AddMiniService(
15-
this IServiceCollection services,
14+
public static IServiceCollection AddMiniService(this IServiceCollection services,
1615
Action<IServiceCollection, IServiceProvider> preHook = null)
1716
{
1817
services.AddFeatureToggle();
@@ -24,43 +23,32 @@ public static IServiceCollection AddMiniService(
2423
var env = svcProvider.GetRequiredService<IHostingEnvironment>();
2524
var feature = svcProvider.GetRequiredService<IFeature>();
2625

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

30-
// RestClient out of the box
3128
services.AddRestClientCore();
3229

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

36-
// #3
3732
if (feature.IsEnabled("CleanArch"))
3833
services.AddCleanArch(config.LoadFullAssemblies());
3934

4035
services.AddCacheCore();
4136

42-
// #4
4337
if (feature.IsEnabled("ApiVersion"))
4438
services.AddApiVersionCore(config);
4539

46-
// #5
4740
services.AddMvcCore(config);
4841

49-
// #6
5042
services.AddDetailExceptionCore();
5143

52-
// #7
5344
if (feature.IsEnabled("AuthN"))
5445
services.AddAuthNCore(config, env);
5546

56-
// #8
5747
if (feature.IsEnabled("OpenApi"))
5848
services.AddOpenApiCore(config, feature);
5949

60-
// #9
6150
services.AddCorsCore();
6251

63-
// #10
6452
services.AddHeaderForwardCore(env);
6553

6654
if (feature.IsEnabled("OpenApi:Profiler"))

0 commit comments

Comments
 (0)