2025-02-27 10:09:03 +01:00
|
|
|
|
using CodexClient;
|
2024-10-30 11:09:13 +01:00
|
|
|
|
using Logging;
|
2025-02-26 14:05:41 +01:00
|
|
|
|
using WebUtils;
|
2024-09-12 14:38:15 +02:00
|
|
|
|
|
|
|
|
|
|
namespace AutoClient
|
|
|
|
|
|
{
|
|
|
|
|
|
public class App
|
|
|
|
|
|
{
|
|
|
|
|
|
public App(Configuration config)
|
|
|
|
|
|
{
|
|
|
|
|
|
Config = config;
|
|
|
|
|
|
|
|
|
|
|
|
Log = new LogSplitter(
|
|
|
|
|
|
new FileLog(Path.Combine(config.LogPath, "autoclient")),
|
|
|
|
|
|
new ConsoleLog()
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
Generator = CreateGenerator();
|
2024-09-12 15:03:06 +02:00
|
|
|
|
Performance = new Performance(new LogSplitter(
|
|
|
|
|
|
new FileLog(Path.Combine(config.LogPath, "performance")),
|
|
|
|
|
|
new ConsoleLog()
|
|
|
|
|
|
));
|
2024-09-12 14:38:15 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Configuration Config { get; }
|
|
|
|
|
|
public ILog Log { get; }
|
|
|
|
|
|
public IFileGenerator Generator { get; }
|
|
|
|
|
|
public CancellationTokenSource Cts { get; } = new CancellationTokenSource();
|
2024-09-12 15:03:06 +02:00
|
|
|
|
public Performance Performance { get; }
|
2024-09-12 14:38:15 +02:00
|
|
|
|
|
|
|
|
|
|
private IFileGenerator CreateGenerator()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (Config.FileSizeMb > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
return new RandomFileGenerator(Config, Log);
|
|
|
|
|
|
}
|
|
|
|
|
|
return new ImageGenerator(Log);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-02-26 14:05:41 +01:00
|
|
|
|
|
|
|
|
|
|
public class AutoClientWebTimeSet : IWebCallTimeSet
|
|
|
|
|
|
{
|
|
|
|
|
|
public TimeSpan HttpCallTimeout()
|
|
|
|
|
|
{
|
|
|
|
|
|
return TimeSpan.FromMinutes(30.0);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public TimeSpan HttpRetryTimeout()
|
|
|
|
|
|
{
|
|
|
|
|
|
return HttpCallTimeout() * 2.2;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// After a failed HTTP call, wait this long before trying again.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public TimeSpan HttpCallRetryDelay()
|
|
|
|
|
|
{
|
|
|
|
|
|
return TimeSpan.FromMinutes(1.0);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-09-12 14:38:15 +02:00
|
|
|
|
}
|