protected override async Task <ContractExecutionResult> ProcessAsyncEx <T>(T item) { if (!(item is CompactionTagFileRequest request)) { Logger.LogWarning($"{nameof(TagFileProcessExecutor)} Invalid Request passed in. Expected {typeof(CompactionTagFileRequest).Name} but got {(item == null ? "null" : item.GetType().Name)}"); return(ContractExecutionResult.ErrorResult("Invalid Request")); } request.Validate(); Logger.LogInformation($"{nameof(TagFileProcessExecutor)} Received Tag File with filename: {request.FileName}. TCC Org: {request.OrgId}. Data Length: {request.Data.Length}"); var result = ContractExecutionResult.ErrorResult("Not processed"); var internalProcessingError = false; try { result = await TRexTagFileProxy.SendTagFile(request); } catch (Exception e) { Logger.LogError(e, $"{nameof(TagFileProcessExecutor)} Failed to connect to TRex. Tag file {request.FileName}"); internalProcessingError = true; } internalProcessingError = IsInternalError(internalProcessingError, result.Code); // If we failed to connect to trex (or other retry-able error), // we want to either put it separate folder or not delete from SQS que // If the tag file was accepted, and not processed for a real reason (e.g no project found at seed position) // then we can to archive it, as it was successfully processed with no change to the datamodel await using (var data = new MemoryStream(request.Data)) { Logger.LogInformation($"{nameof(TagFileProcessExecutor)} Uploading Tag File {request.FileName}"); var path = GetS3Key(request.FileName); if (internalProcessingError) { path = $"{CONNECTION_ERROR_FOLDER}/{path}"; } if (!internalProcessingError || ArchiveOnInternalError) { TransferProxyFactory.NewProxy(TransferProxyType.TagFileGatewayArchive).Upload(data, path); Logger.LogInformation($"{nameof(TagFileProcessExecutor)} Successfully uploaded Tag File {request.FileName}"); } else { Logger.LogInformation($"{nameof(TagFileProcessExecutor)} No S3 upload as NoArchiveOnInternalError set. Tag File {request.FileName}"); } } if (internalProcessingError) { Logger.LogError($"{nameof(TagFileProcessExecutor)} InternalProcessingError {result.Code} {request.FileName} archiveFlag: {ArchiveOnInternalError}"); return(ContractExecutionResult.ErrorResult("Failed to connect to backend")); } return(result); }
public void Ensure_all_proxy_types_supported_in_factory() { var factory = new TransferProxyFactory(serviceProvider.GetRequiredService <IConfigurationStore>(), serviceProvider.GetRequiredService <ILoggerFactory>()); foreach (TransferProxyType type in Enum.GetValues(typeof(TransferProxyType))) { Assert.False(factory.NewProxy(type) == null); } }
public void Creation() { var factory = new TransferProxyFactory(serviceProvider.GetRequiredService <IConfigurationStore>(), serviceProvider.GetRequiredService <ILoggerFactory>()); Assert.False(factory == null); }