62 lines
1.6 KiB
C#
Raw Normal View History

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();
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();
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
}