IMdpTargetPushExecutor.cs 1.2 KB

12345678910111213141516171819202122232425262728293031
  1. using Admin.NET.Plugin.AiDOP.Entity.DataPlatform;
  2. namespace Admin.NET.Plugin.AiDOP.DataPlatform.Executors;
  3. /// <summary>出站执行器:按 mdp_source.source_type 推送单条 Outbox。</summary>
  4. public interface IMdpTargetPushExecutor
  5. {
  6. /// <summary>API / DB</summary>
  7. string SupportedType { get; }
  8. Task<MdpPushResult> PushAsync(MdpSource source, MdpOutbox item, CancellationToken ct = default);
  9. }
  10. public sealed class MdpPushResult
  11. {
  12. public bool Success { get; set; }
  13. public int AffectedRows { get; set; }
  14. public string? ResponseJson { get; set; }
  15. public string? ErrorMessage { get; set; }
  16. /// <summary>true 表示识别为「已处理过」,幂等跳过,应记为成功。</summary>
  17. public bool IdempotentSkip { get; set; }
  18. public static MdpPushResult Ok(int affected = 1, string? response = null) =>
  19. new() { Success = true, AffectedRows = affected, ResponseJson = response };
  20. public static MdpPushResult Skip(string? response = null) =>
  21. new() { Success = true, IdempotentSkip = true, AffectedRows = 0, ResponseJson = response };
  22. public static MdpPushResult Fail(string error, string? response = null) =>
  23. new() { Success = false, ErrorMessage = error, ResponseJson = response };
  24. }