You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.7 KiB
61 lines
1.7 KiB
using System;
|
|
using Ksat.Logging;
|
|
using Ksat.Supplyment.Library.Uploader;
|
|
using Ksat.Supplyment.Library.Model.Uploader;
|
|
using S3Demo.Model.Uploader;
|
|
|
|
namespace S3Demo.Uploader
|
|
{
|
|
public class S3UploadOperator : IUploaderOperator<string>
|
|
{
|
|
//Log
|
|
private ILogger sLog = LoggerFactory.ForContext<S3UploadOperator>();
|
|
public string ConvertCacheToRequest(string cache)
|
|
{
|
|
return cache;
|
|
}
|
|
|
|
public string ConvertRequestToCachel(string requestData)
|
|
{
|
|
return requestData;
|
|
}
|
|
|
|
public bool ShouldRetryRequest(UploadModel<string> requestModel, out string cancelReason)
|
|
{
|
|
if (DateTime.Now.Subtract(requestModel.CreateAt).TotalSeconds > 600)
|
|
{
|
|
cancelReason = "exceed 600s";
|
|
return false;
|
|
}
|
|
if (requestModel.RetryCount > 5)
|
|
{
|
|
cancelReason = "exceed 5";
|
|
return false;
|
|
}
|
|
cancelReason = null;
|
|
return true;
|
|
}
|
|
|
|
public bool ShouldStartRequest(UploadModel<string> requestModel, out string cancelReason)
|
|
{
|
|
if (DateTime.Now.Subtract(requestModel.CreateAt).TotalSeconds > 600)
|
|
{
|
|
cancelReason = "exceed 600s";
|
|
return false;
|
|
}
|
|
if (requestModel.RetryCount > 5)
|
|
{
|
|
cancelReason = "exceed 5";
|
|
return false;
|
|
}
|
|
cancelReason = null;
|
|
return true;
|
|
}
|
|
|
|
public IUploaderRequest<string> UploadData(string data)
|
|
{
|
|
return new S3UploadRequest() { RequestData = data };
|
|
}
|
|
}
|
|
}
|