private async Task EnqueueFromSnapshotsAsync(RuleContext context, CancellationToken ct) { var errors = 0; await foreach (var(job, ex, _) in ruleService.CreateSnapshotJobsAsync(context, ct)) { if (job != null) { await ruleEventRepository.EnqueueAsync(job, ex); } else if (ex != null) { errors++; if (errors >= MaxErrors) { throw ex; } log.LogWarning(ex, w => w .WriteProperty("action", "runRule") .WriteProperty("status", "failedPartially")); } } }
private async Task EnqueueFromSnapshotsAsync(RuleContext context, CancellationToken ct) { var errors = 0; await foreach (var job in ruleService.CreateSnapshotJobsAsync(context, ct)) { if (job.Job != null && job.SkipReason == SkipReason.None) { await ruleEventRepository.EnqueueAsync(job.Job, job.EnrichmentError, ct); } else if (job.EnrichmentError != null) { errors++; if (errors >= MaxErrors) { throw job.EnrichmentError; } log.LogWarning(job.EnrichmentError, w => w .WriteProperty("action", "runRule") .WriteProperty("status", "failedPartially")); } } }
private async Task EnqueueFromSnapshotsAsync(IRuleEntity rule) { var errors = 0; await foreach (var(job, ex) in ruleService.CreateSnapshotJobsAsync(rule.RuleDef, rule.Id, rule.AppId.Id)) { if (job != null) { await ruleEventRepository.EnqueueAsync(job, ex); } else if (ex != null) { errors++; if (errors >= MaxErrors) { throw ex; } log.LogWarning(ex, w => w .WriteProperty("action", "runRule") .WriteProperty("status", "failedPartially")); } } }
private async Task EnqueueFromSnapshotsAsync(RuleContext context, CancellationToken ct) { var errors = 0; await foreach (var job in ruleService.CreateSnapshotJobsAsync(context, ct)) { if (job.Job != null && job.SkipReason == SkipReason.None) { await ruleEventRepository.EnqueueAsync(job.Job, job.EnrichmentError, ct); } else if (job.EnrichmentError != null) { errors++; if (errors >= MaxErrors) { throw job.EnrichmentError; } log.LogWarning(job.EnrichmentError, "Failed to run rule with ID {ruleId}, continue with next job.", context.RuleId); } } }