add hangfire

This commit is contained in:
2025-01-16 22:05:59 +08:00
parent e53048a980
commit afea9c82bd
7 changed files with 172 additions and 30 deletions
+22
View File
@@ -0,0 +1,22 @@
namespace SimApi.Configurations;
public class SimApiJobOptions
{
/// <summary>
/// WebUi地址,设置为null表示不启用
/// </summary>
public string? DashboardUrl { get; set; } = "/jobs";
public string DashboardAuthUser { get; set; } = "admin";
public string DashboardAuthPass { get; set; } = "Admin@123!";
public string? RedisConfiguration { get; set; }
public int? Database { get; set; } = null;
public SimApiJobServerConfig[] Servers { get; set; } = [new()];
}
public class SimApiJobServerConfig()
{
public string[] Queues { get; set; } = ["default"];
public int WorkerNum { get; set; } = 50;
}
+17 -1
View File
@@ -5,6 +5,13 @@ namespace SimApi.Configurations;
public class SimApiOptions
{
public string? RedisConfiguration { get; set; }
/// <summary>
/// 是否启用后台任务系统 *基于Hangfire
/// </summary>
public bool EnableJob { get; set; } = false;
/// <summary>
/// 启用全部Cors,对于开发前后分离的时候很有用。
/// default: true
@@ -36,7 +43,7 @@ public class SimApiOptions
/// default: true
/// </summary>
public bool EnableSimApiException { get; set; } = true;
/// <summary>
/// 启用返回结果拦截
/// </summary>
@@ -71,6 +78,10 @@ public class SimApiOptions
/// </summary>
public bool EnableSynapse { get; set; }
/// <summary>
/// 配置Job
/// </summary>
public SimApiJobOptions SimApiJobOptions { get; set; } = new();
/// <summary>
/// Swagger文档相关配置,需要启用 EnableSimApiDoc
@@ -103,4 +114,9 @@ public class SimApiOptions
{
options?.Invoke(SimApiStorageOptions);
}
public void ConfigureSimApiJob(Action<SimApiJobOptions>? options = null)
{
options?.Invoke(SimApiJobOptions);
}
}