Skip to content

Commit d220d21

Browse files
feat: transfer hangfire dashboard to apigateway
1 parent eab2e10 commit d220d21

File tree

4 files changed

+26
-5
lines changed

4 files changed

+26
-5
lines changed

HwProj.APIGateway/HwProj.APIGateway.API/HwProj.APIGateway.API.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
</PropertyGroup>
1111

1212
<ItemGroup>
13+
<PackageReference Include="Hangfire" Version="1.8.6" />
14+
<PackageReference Include="Hangfire.AspNetCore" Version="1.8.6" />
15+
<PackageReference Include="Hangfire.Core" Version="1.8.6" />
16+
<PackageReference Include="Hangfire.Dashboard.Authorization" Version="3.0.1" />
1317
<PackageReference Include="Microsoft.AspNetCore.All" />
1418
<PackageReference Include="Microsoft.AspNetCore.App" />
1519
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.2.3" />
@@ -20,6 +24,7 @@
2024
<ProjectReference Include="..\..\HwProj.AuthService\HwProj.AuthService.Client\HwProj.AuthService.Client.csproj" />
2125
<ProjectReference Include="..\..\HwProj.Common\HwProj.Utils\HwProj.Utils.csproj" />
2226
<ProjectReference Include="..\..\HwProj.CoursesService\HwProj.CoursesService.Client\HwProj.CoursesService.Client.csproj" />
27+
<ProjectReference Include="..\..\HwProj.NotificationsService\HwProj.NotificationsService.API\HwProj.NotificationsService.API.csproj" />
2328
<ProjectReference Include="..\..\HwProj.NotificationsService\HwProj.NotificationsService.Client\HwProj.NotificationsService.Client.csproj" />
2429
<ProjectReference Include="..\..\HwProj.SolutionsService\HwProj.SolutionsService.Client\HwProj.SolutionsService.Client.csproj" />
2530
</ItemGroup>

HwProj.APIGateway/HwProj.APIGateway.API/Startup.cs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using HwProj.AuthService.Client;
1+
using Hangfire;
2+
using Hangfire.SqlServer;
3+
using HwProj.AuthService.Client;
24
using HwProj.CoursesService.Client;
35
using HwProj.NotificationsService.Client;
46
using HwProj.SolutionsService.Client;
@@ -25,8 +27,15 @@ public void ConfigureServices(IServiceCollection services)
2527
{
2628
services.ConfigureHwProjServices("API Gateway");
2729

28-
const string authenticationProviderKey = "GatewayKey";
30+
services.AddHangfire(configuration => configuration
31+
.SetDataCompatibilityLevel(CompatibilityLevel.Version_180)
32+
.UseSimpleAssemblyNameTypeSerializer()
33+
.UseRecommendedSerializerSettings()
34+
.UseSqlServerStorage(Configuration.GetConnectionString("HangfireConnection")));
35+
2936

37+
const string authenticationProviderKey = "GatewayKey";
38+
3039
services.AddAuthentication()
3140
.AddJwtBearer(authenticationProviderKey, x =>
3241
{
@@ -54,6 +63,11 @@ public void ConfigureServices(IServiceCollection services)
5463
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
5564
{
5665
app.ConfigureHwProj(env, "API Gateway");
66+
67+
if (env.IsDevelopment())
68+
{
69+
app.UseHangfireDashboard("/jobs");
70+
}
5771
}
5872
}
59-
}
73+
}

HwProj.APIGateway/HwProj.APIGateway.API/appsettings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,9 @@
44
"Courses": "http://localhost:5002",
55
"Notifications": "http://localhost:5006",
66
"Solutions": "http://localhost:5007"
7+
},
8+
9+
"ConnectionStrings": {
10+
"HangfireConnection": "Server=(localdb)\\mssqllocaldb;Database=HangfireDB;Trusted_Connection=True;"
711
}
812
}

HwProj.NotificationsService/HwProj.NotificationsService.API/Startup.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ public void ConfigureServices(IServiceCollection services)
3131
{
3232
var connectionString = ConnectionString.GetConnectionString(Configuration);
3333

34-
// Add Hangfire services.
3534
services.AddHangfire(configuration => configuration
3635
.SetDataCompatibilityLevel(CompatibilityLevel.Version_180)
3736
.UseSimpleAssemblyNameTypeSerializer()
@@ -89,7 +88,6 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, IEventBu
8988
eventBustSubscriber.Subscribe<PasswordRecoveryEvent, PasswordRecoveryEventHandler>();
9089
}
9190

92-
app.UseHangfireDashboard();
9391
app.ConfigureHwProj(env, "Notifications API", context);
9492
}
9593
}

0 commit comments

Comments
 (0)