public async Task Update(InferenceRequest inferenceRequest, InferenceRequestStatus status) { Guard.Against.Null(inferenceRequest, nameof(inferenceRequest)); if (status == InferenceRequestStatus.Success) { _logger.Log(LogLevel.Information, $"Archiving inference request JobId={inferenceRequest.JobId}, TransactionId={inferenceRequest.TransactionId}."); inferenceRequest.State = InferenceRequestState.Completed; inferenceRequest.Status = InferenceRequestStatus.Success; await MoveToArchive(inferenceRequest); await Delete(inferenceRequest); } else { if (++inferenceRequest.TryCount > MaxRetryLimit) { _logger.Log(LogLevel.Information, $"Exceeded maximum retries; removing inference request JobId={inferenceRequest.JobId}, TransactionId={inferenceRequest.TransactionId} from Inference Request store."); inferenceRequest.State = InferenceRequestState.Completed; inferenceRequest.Status = InferenceRequestStatus.Fail; await MoveToArchive(inferenceRequest); await Delete(inferenceRequest); } else { _logger.Log(LogLevel.Information, $"Updating inference request JobId={inferenceRequest.JobId}, TransactionId={inferenceRequest.TransactionId} to Queued."); inferenceRequest.State = InferenceRequestState.Queued; await UpdateInferenceRequest(inferenceRequest); _logger.Log(LogLevel.Information, $"Inference request JobId={inferenceRequest.JobId}, TransactionId={inferenceRequest.TransactionId} added back to Inference Request store for retry."); } } _cache.Remove(inferenceRequest.JobId); }
public async Task Update(InferenceRequest inferenceRequest, InferenceRequestStatus status) { Guard.Against.Null(inferenceRequest, nameof(inferenceRequest)); using var loggerScope = _logger.BeginScope(new LogginDataDictionary <string, object> { { "JobId", inferenceRequest.JobId }, { "TransactionId", inferenceRequest.TransactionId } }); if (status == InferenceRequestStatus.Success) { inferenceRequest.State = InferenceRequestState.Completed; inferenceRequest.Status = InferenceRequestStatus.Success; } else { if (++inferenceRequest.TryCount > MaxRetryLimit) { _logger.Log(LogLevel.Information, $"Exceeded maximum retries."); inferenceRequest.State = InferenceRequestState.Completed; inferenceRequest.Status = InferenceRequestStatus.Fail; } else { _logger.Log(LogLevel.Information, $"Will retry later."); inferenceRequest.State = InferenceRequestState.Queued; } } await Save(inferenceRequest); }