public async Task <IActionResult> AddExecutionStepLog([FromRoute] long id, [FromBody] Execution.StepState stepState, [FromQuery] Execution.ExecutionState?result) { this.logger.LogInformation("Received execution step log."); this.logger.LogInformation($"ExecutionId: '{id}'. Result: {result}."); this.logger.LogDebug($"Logs:"); this.logger.LogDebug(string.Join('\n', stepState.Log)); using var db = this.databaseFactory(); var collection = db.GetCollection <Execution>(); var execution = collection.FindById(id); execution.StepsStates.Add(stepState); if (result.HasValue) { if (result.Value == Execution.ExecutionState.Failed) { if (execution.State != Execution.ExecutionState.Retrying || execution.RetryCount < 3) { await Task.Delay(3000); lock (locker) { if (!queues.ContainsKey(execution.Instance)) { queues.Add(execution.Instance, this.queueFactory(execution.Instance)); } } var queue = queues[execution.Instance]; using var session = queue.OpenSession(); session.Enqueue(new ValueTuple <long>(execution.Id).Serialize()); session.Flush(); execution.RetryCount += 1; execution.State = Execution.ExecutionState.Retrying; } else { execution.State = result.Value; this.logger.LogTrace($"Execution {id} failed."); } } else { execution.State = result.Value; this.logger.LogTrace($"Execution {id} finished."); } } collection.Update(execution); return(Ok()); }
public Task SendExecutionLog(long executionId, bool isLastStep, Execution.StepState stepState, CancellationToken cancellation = default) => PutAsync( this.api