using Admin.NET.Plugin.AiDOP.Entity.DataPlatform;
namespace Admin.NET.Plugin.AiDOP.DataPlatform.Executors;
/// 出站执行器:按 mdp_source.source_type 推送单条 Outbox。
public interface IMdpTargetPushExecutor
{
/// API / DB
string SupportedType { get; }
Task PushAsync(MdpSource source, MdpOutbox item, CancellationToken ct = default);
}
public sealed class MdpPushResult
{
public bool Success { get; set; }
public int AffectedRows { get; set; }
public string? ResponseJson { get; set; }
public string? ErrorMessage { get; set; }
/// true 表示识别为「已处理过」,幂等跳过,应记为成功。
public bool IdempotentSkip { get; set; }
public static MdpPushResult Ok(int affected = 1, string? response = null) =>
new() { Success = true, AffectedRows = affected, ResponseJson = response };
public static MdpPushResult Skip(string? response = null) =>
new() { Success = true, IdempotentSkip = true, AffectedRows = 0, ResponseJson = response };
public static MdpPushResult Fail(string error, string? response = null) =>
new() { Success = false, ErrorMessage = error, ResponseJson = response };
}