Skip to content

Commit a570f61

Browse files
committed
#27 even better for health check :)
1 parent 5b5d695 commit a570f61

File tree

9 files changed

+60
-40
lines changed

9 files changed

+60
-40
lines changed

README.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,22 @@
66

77
A set of cloud-native tools and utilities for .NET Core.
88

9+
### Features
10+
11+
- Simple libraries. No frameworks. Little abstraction.
12+
- Opt-in and out of the box [features](https://github.com/cloudnative-netcore/netcorekit/wiki/Miniservice-template-guidance) with [Feature Toggles](https://martinfowler.com/articles/feature-toggles.html) technique.
13+
- Generic repository for data persistence.
14+
- Adhere to [twelve-factor app paradigm](https://12factor.net) and more.
15+
- Resilience and health check out of the box.
16+
- Easy for configuration management.
17+
- [Domain-driven Design](https://en.wikipedia.org/wiki/Domain-driven_design) in mind.
18+
- Simply [Clean Architecture](http://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html) supports.
19+
- Authentication/Authorization with OAuth 2.0 and OpenID Connect.
20+
- Clean and demystify error, debug logs.
21+
- API versioning from Docker container to WebAPI.
22+
- Documentation template with OpenAPI documentation.
23+
- Work natively with Kubernetes or even with Service Mesh(Istio).
24+
925
## Less code to get starting
1026

1127
Small, lightweight, cloud-native out of the box, and much more simple to get starting with miniservices approach. [Why miniservices?](https://thenewstack.io/miniservices-a-realistic-alternative-to-microservices)
@@ -70,22 +86,6 @@ public class Startup
7086

7187
</details>
7288

73-
### Features
74-
75-
- Simple libraries. No frameworks. Little abstraction.
76-
- Modular (Easy to swap out Utils, Domain, AspNetCore, Clean Architecture, Open API, Entity Framework Core, Event Bus...)
77-
- Adhere to [twelve-factor app paradigm](https://12factor.net) and more.
78-
- Resilience and health check out of the box.
79-
- Easy for configuration management.
80-
- Simply clean architecture supports.
81-
- Authentication/Authorization with OAuth 2.0 and OpenID Connect.
82-
- Clean and demystify error, debug logs.
83-
- API versioning from Docker container to WebAPI.
84-
- Documentation template with OpenAPI documentation.
85-
- Work natively with Kubernetes or even with Service Mesh.
86-
87-
More information about the number of features can be find at [List of features](https://github.com/cloudnative-netcore/netcorekit/wiki/Miniservice-template-guidance)
88-
8989
### Contributing
9090

9191
1. Fork it!

samples/BiMonetaryApi/NetCoreKit.Samples.BiMonetaryApi.csproj

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
<Project Sdk="Microsoft.NET.Sdk.Web">
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
44
<TargetFramework>netcoreapp2.1</TargetFramework>
55
<AspNetCoreHostingModel>inprocess</AspNetCoreHostingModel>
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" />
129
<PackageReference Include="Microsoft.AspNetCore.App" />
1310
</ItemGroup>
1411

samples/BiMonetaryApi/Startup.cs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using BeatPulse.UI;
21
using Microsoft.AspNetCore.Builder;
32
using Microsoft.Extensions.DependencyInjection;
43
using NetCoreKit.Infrastructure.AspNetCore.Miniservice;
@@ -9,23 +8,12 @@ public class Startup
98
{
109
public void ConfigureServices(IServiceCollection services)
1110
{
12-
services
13-
.AddMongoMiniService()
14-
.AddBeatPulse()
15-
.AddBeatPulseUI();
11+
services.AddMongoMiniService();
1612
}
1713

1814
public void Configure(IApplicationBuilder app)
1915
{
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();
16+
app.UseMiniService();
2917
}
3018
}
3119
}

samples/BiMonetaryApi/appsettings.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"ApiVersion": { "Enabled": true },
1818
"OpenApi": {
1919
"Enabled": true,
20-
"UI": { "Enabled": true },
20+
"OpenApiUI": { "Enabled": true },
2121
"ApiInfo": {
2222
"Title": "BiMonetary API",
2323
"Description": "An application with Swagger, Swashbuckle, and API versioning.",
@@ -39,7 +39,8 @@
3939
"example2_api_scope": "Example 2 APIs"
4040
},
4141
"Audience": "api"
42-
}
42+
},
43+
"HealthUI": { "Enabled": true }
4344
},
4445
"BeatPulse-UI": {
4546
"Liveness": [

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Diagnostics;
22
using System.Reflection;
3+
using BeatPulse.UI;
34
using IdentityServer4.Models;
45
using Microsoft.AspNetCore.Builder;
56
using Microsoft.AspNetCore.Diagnostics;
@@ -93,6 +94,15 @@ public static IApplicationBuilder UseMiniService(this IApplicationBuilder app)
9394

9495
app.UseMiddleware<ErrorHandlerMiddleware>();
9596

97+
app
98+
.UseBeatPulse(options =>
99+
{
100+
options.ConfigurePath("healthz") //default hc
101+
.ConfigureTimeout(1500) // default -1 infinitely
102+
.ConfigureDetailedOutput(true, true); //default (true,false)
103+
})
104+
.UseBeatPulseUI();
105+
96106
if (feature.IsEnabled("OpenApi:Profiler"))
97107
app.UseMiddleware<MiniProfilerMiddleware>();
98108

@@ -132,7 +142,7 @@ public static IApplicationBuilder UseMiniService(this IApplicationBuilder app)
132142
if (feature.IsEnabled("OpenApi"))
133143
app.UseSwagger();
134144

135-
if (feature.IsEnabled("OpenApi:UI"))
145+
if (feature.IsEnabled("OpenApi:OpenApiUI"))
136146
app.UseSwaggerUI(
137147
c =>
138148
{
@@ -153,13 +163,11 @@ public static IApplicationBuilder UseMiniService(this IApplicationBuilder app)
153163
}
154164

155165
if (feature.IsEnabled("OpenApi:Profiler"))
156-
{
157166
c.IndexStream = () =>
158167
typeof(ServiceCollectionExtensions)
159168
.GetTypeInfo()
160169
.Assembly
161170
.GetManifestResourceStream("NetCoreKit.Infrastructure.AspNetCore.Miniservice.Swagger.index.html");
162-
}
163171
});
164172

165173
return app;

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using System;
22
using System.Linq;
3+
using BeatPulse.Core;
4+
using BeatPulse.UI;
35
using Microsoft.AspNetCore.Hosting;
46
using Microsoft.EntityFrameworkCore;
57
using Microsoft.Extensions.Configuration;
@@ -16,6 +18,7 @@ namespace NetCoreKit.Infrastructure.AspNetCore.Miniservice
1618
public static partial class ServiceCollectionExtensions
1719
{
1820
public static IServiceCollection AddEfCoreMiniService<TDbContext>(this IServiceCollection services,
21+
Action<BeatPulseContext> beatPulseCtx = null,
1922
Action<IServiceCollection> preDbWorkHook = null,
2023
Action<IServiceCollection, IServiceProvider> postDbWorkHook = null)
2124
where TDbContext : DbContext
@@ -77,6 +80,11 @@ public static IServiceCollection AddEfCoreMiniService<TDbContext>(this IServiceC
7780

7881
if (feature.IsEnabled("OpenApi:Profiler"))
7982
services.AddApiProfilerCore();
83+
84+
services.AddBeatPulse(beatPulseCtx);
85+
86+
if (feature.IsEnabled("HealthUI"))
87+
services.AddBeatPulseUI();
8088
}
8189

8290
return services;

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
using System;
2+
using BeatPulse.Core;
3+
using BeatPulse.UI;
24
using Microsoft.AspNetCore.Hosting;
35
using Microsoft.Extensions.Configuration;
46
using Microsoft.Extensions.DependencyInjection;
@@ -13,6 +15,7 @@ namespace NetCoreKit.Infrastructure.AspNetCore.Miniservice
1315
public static partial class ServiceCollectionExtensions
1416
{
1517
public static IServiceCollection AddMongoMiniService(this IServiceCollection services,
18+
Action<BeatPulseContext> beatPulseCtx = null,
1619
Action<IServiceCollection> preDbWorkHook = null,
1720
Action<IServiceCollection, IServiceProvider> postDbWorkHook = null)
1821
{
@@ -64,6 +67,11 @@ public static IServiceCollection AddMongoMiniService(this IServiceCollection ser
6467

6568
if (feature.IsEnabled("OpenApi:Profiler"))
6669
services.AddApiProfilerCore();
70+
71+
services.AddBeatPulse(beatPulseCtx);
72+
73+
if (feature.IsEnabled("HealthUI"))
74+
services.AddBeatPulseUI();
6775
}
6876

6977
return services;

src/NetCoreKit.Infrastructure.AspNetCore.Miniservice/NetCoreKit.Infrastructure.AspNetCore.Miniservice.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
<PackageReference Include="MediatR" Version="5.1.0" />
5151
<PackageReference Include="Scrutor" Version="3.0.1" />
5252
<PackageReference Include="System.Reactive" Version="4.1.0" />
53+
<PackageReference Include="BeatPulse" Version="3.0.0" />
54+
<PackageReference Include="BeatPulse.UI" Version="3.0.1" />
5355
</ItemGroup>
5456

5557
<ItemGroup>

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
using System;
2+
using BeatPulse.Core;
3+
using BeatPulse.UI;
24
using Microsoft.AspNetCore.Hosting;
35
using Microsoft.Extensions.Configuration;
46
using Microsoft.Extensions.DependencyInjection;
@@ -12,7 +14,8 @@ namespace NetCoreKit.Infrastructure.AspNetCore.Miniservice
1214
public static partial class ServiceCollectionExtensions
1315
{
1416
public static IServiceCollection AddMiniService(this IServiceCollection services,
15-
Action<IServiceCollection, IServiceProvider> preHook = null)
17+
Action<IServiceCollection, IServiceProvider> preHook = null,
18+
Action<BeatPulseContext> beatPulseCtx = null)
1619
{
1720
services.AddFeatureToggle();
1821

@@ -53,6 +56,11 @@ public static IServiceCollection AddMiniService(this IServiceCollection services
5356

5457
if (feature.IsEnabled("OpenApi:Profiler"))
5558
services.AddApiProfilerCore();
59+
60+
services.AddBeatPulse(beatPulseCtx);
61+
62+
if (feature.IsEnabled("HealthUI"))
63+
services.AddBeatPulseUI();
5664
}
5765

5866
return services;

0 commit comments

Comments
 (0)