AdoEtlRunnerDesignation.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. namespace Admin.NET.Plugin.AiDOP.Entity.SmartOps;
  2. /// <summary>
  3. /// ETL 执行机指派。全表**只有一行**,记录当前被指派跑定时 ETL 的**槽位**。
  4. ///
  5. /// <para><b>为什么指派不能存在 <c>ado_etl_instance</c> 上</b>:实例标识是
  6. /// <c>机器名:进程ID:启动时间</c>(见 <c>AidopInstanceIdentity</c>,进程级唯一是刻意的),
  7. /// 于是「指派」一旦挂在实例行上,就绑死在一次进程化身上——执行机每重启一次,
  8. /// 指派必然留在一行死记录上,全库变成零台存活执行机,定时 ETL 静默停摆。
  9. /// 2026-09-28 实测即是此情形:03:40 扇出 28 条 AUTO_NIGHTLY 的实例 04:10 退出,
  10. /// 队列此后无人可领。角色是部署槽位的属性,不是进程化身的属性,故独立成表。</para>
  11. ///
  12. /// <para><b>「最多一台执行机」由结构保证</b>:主键固定为 <see cref="SingletonId"/>,
  13. /// 表里放不下第二行,无需再靠事务先清后置。这比原来的写入侧约束更强——
  14. /// 并发指派会被主键挡住,而不是依赖调用方守规矩。</para>
  15. ///
  16. /// <para><b>无租户列是刻意的</b>:指派是部署事实,不属于任何租户。
  17. /// 本类不实现租户过滤接口,SqlSugar 不会给它加租户条件。</para>
  18. /// </summary>
  19. [SugarTable("ado_etl_runner_designation", "ETL执行机指派")]
  20. public class AdoEtlRunnerDesignation
  21. {
  22. /// <summary>全表唯一一行的主键值。</summary>
  23. public const long SingletonId = 1;
  24. [SugarColumn(ColumnName = "id", IsPrimaryKey = true, IsIdentity = false)]
  25. public long Id { get; set; } = SingletonId;
  26. /// <summary>
  27. /// 被指派的槽位码,与进程侧 <c>AidopInstanceIdentity.SlotCode</c> 比对。
  28. /// 为 null / 空表示「当前无指派」——此后无人跑定时 ETL,这是允许的状态。
  29. /// </summary>
  30. [SugarColumn(ColumnName = "slot_code", Length = 128, IsNullable = true)]
  31. public string SlotCode { get; set; }
  32. /// <summary>操作人账号,仅供审计与页面展示。</summary>
  33. [SugarColumn(ColumnName = "assigned_by", Length = 64, IsNullable = true)]
  34. public string AssignedBy { get; set; }
  35. [SugarColumn(ColumnName = "assigned_at", IsNullable = true)]
  36. public DateTime? AssignedAt { get; set; }
  37. [SugarColumn(ColumnName = "remark", Length = 512, IsNullable = true)]
  38. public string Remark { get; set; }
  39. [SugarColumn(ColumnName = "create_time")]
  40. public DateTime CreateTime { get; set; }
  41. [SugarColumn(ColumnName = "update_time")]
  42. public DateTime UpdateTime { get; set; }
  43. }