优化迁移Host,移除一些不必要的组件

This commit is contained in:
zenghongyao 2025-05-21 10:45:18 +08:00
parent 469ea285f2
commit 76019141f1
4 changed files with 6 additions and 64 deletions

View File

@ -1,7 +1,4 @@
//using Hangfire;
//using Hangfire.Redis.StackExchange;
using JiShe.CollectBus.Migration.Host.Hangfire;
using JiShe.CollectBus.Migration.Host.HealthChecks;
using JiShe.CollectBus.Migration.Host.HealthChecks;
using JiShe.CollectBus.Migration.Host.Swaggers;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.DataProtection;
@ -12,7 +9,6 @@ using StackExchange.Redis;
using System.Text;
using Volo.Abp.AspNetCore.Auditing;
using Volo.Abp.Auditing;
using Volo.Abp.BackgroundJobs;
using Volo.Abp.Caching;
using Volo.Abp.Modularity;
@ -21,33 +17,6 @@ namespace JiShe.CollectBus.Migration.Host
{
public partial class CollectBusMigrationHostModule
{
/// <summary>
/// Configures the hangfire.
/// </summary>
/// <param name="context">The context.</param>
//private void ConfigureHangfire(ServiceConfigurationContext context)
//{
// var redisStorageOptions = new RedisStorageOptions()
// {
// Db = context.Services.GetConfiguration().GetValue<int>("Redis:HangfireDB")
// };
// Configure<AbpBackgroundJobOptions>(options => { options.IsJobExecutionEnabled = false; });
// context.Services.AddHangfire(config =>
// {
// config.UseRedisStorage(
// context.Services.GetConfiguration().GetValue<string>("Redis:Configuration"), redisStorageOptions)
// .WithJobExpirationTimeout(TimeSpan.FromDays(7));
// var delaysInSeconds = new[] { 10, 60, 60 * 3 }; // 重试时间间隔
// const int Attempts = 3; // 重试次数
// config.UseFilter(new AutomaticRetryAttribute() { Attempts = Attempts, DelaysInSeconds = delaysInSeconds });
// //config.UseFilter(new AutoDeleteAfterSuccessAttribute(TimeSpan.FromDays(7)));
// config.UseFilter(new JobRetryLastFilter(Attempts));
// });
// context.Services.AddHangfireServer();
//}
/// <summary>
/// Configures the JWT authentication.
/// </summary>
@ -179,8 +148,8 @@ namespace JiShe.CollectBus.Migration.Host
(
options =>
{
options.IsEnabled = true;
options.EntityHistorySelectors.AddAllEntities();
options.IsEnabled = false;
//options.EntityHistorySelectors.AddAllEntities();
options.ApplicationName = "JiShe.CollectBus.Migration";
}
);

View File

@ -86,7 +86,7 @@ namespace JiShe.CollectBus.Migration.Host
}
//app.UseAuditing();
app.UseAbpSerilogEnrichers();
app.UseUnitOfWork();
//app.UseUnitOfWork();
//app.UseHangfireDashboard("/hangfire", new DashboardOptions
//{
// IgnoreAntiforgeryToken = true

View File

@ -1,29 +0,0 @@
using Hangfire.Common;
using Hangfire.States;
using Serilog;
namespace JiShe.CollectBus.Migration.Host.Hangfire
{
/// <summary>
/// 重试最后一次
/// </summary>
public class JobRetryLastFilter : JobFilterAttribute, IElectStateFilter
{
private int RetryCount { get; }
public JobRetryLastFilter(int retryCount)
{
RetryCount = retryCount;
}
public void OnStateElection(ElectStateContext context)
{
var retryAttempt = context.GetJobParameter<int>("RetryCount");
if (RetryCount == retryAttempt)
{
Log.Error("最后一次重试");
}
}
}
}

View File

@ -46,6 +46,8 @@
<!--<PackageReference Include="Volo.Abp.BackgroundWorkers.Hangfire" Version="8.3.3" />-->
<PackageReference Include="Volo.Abp.Caching.StackExchangeRedis" Version="8.3.3" />
<PackageReference Include="Volo.Abp.Core" Version="8.3.3" />
<PackageReference Include="Volo.Abp.Swashbuckle" Version="8.3.3" />
<!--<PackageReference Include="Hangfire.HttpJob" Version="3.8.5" />
<PackageReference Include="Hangfire.MySqlStorage" Version="2.0.3" />