Mimante 1.9.3 #50
No files matched your search
@@ -185,10 +185,17 @@ public sealed partial class AuctionMonitor : IAuctionRunnerHost, IAsyncDisposabl
|
||||
public void NoteEngineError(AuctionInfo auction, string message, AuctionLogCategory category)
|
||||
{
|
||||
auction.Log.Add(message, LogLevel.Error, category);
|
||||
var s = Settings;
|
||||
if (!_engineErrors.Record(auction.Id, s.EngineErrorAlertCount, s.EngineErrorAlertMinutes)) return;
|
||||
_d.Log.Warn("MOTORE", $"{auction.Name}: {s.EngineErrorAlertCount} errori del motore in {s.EngineErrorAlertMinutes} min, l'ultimo: {message}", auction.Id);
|
||||
EngineErrorRepeated?.Invoke(auction, message);
|
||||
// Si chiama dai catch del motore, anche da quello del thread del cecchino: qui un'eccezione
|
||||
// chiuderebbe il ciclo dell'asta o, sul thread, il processo. Il conteggio e l'avviso non
|
||||
// devono mai lanciare, come BidPlaced e AuctionCompleted.
|
||||
try
|
||||
{
|
||||
var s = Settings;
|
||||
if (!_engineErrors.Record(auction.Id, s.EngineErrorAlertCount, s.EngineErrorAlertMinutes)) return;
|
||||
_d.Log.Warn("MOTORE", $"{auction.Name}: {s.EngineErrorAlertCount} errori del motore in {s.EngineErrorAlertMinutes} min, l'ultimo: {message}", auction.Id);
|
||||
EngineErrorRepeated?.Invoke(auction, message);
|
||||
}
|
||||
catch { /* chi ascolta non ferma il motore */ }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -171,6 +171,21 @@ public class MonitorAgainstSimulatorTests
|
||||
Assert.Equal(new[] { "Uno: 3 errori del motore in 10 min, l'ultimo: Errore nel polling: prova 3" }, engine);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Chi_ascolta_l_errore_ripetuto_non_ferma_il_motore()
|
||||
{
|
||||
var world = new SimWorld(seed: 26, populate: false);
|
||||
var settings = new AppSettings { EngineErrorAlertCount = 1, EngineErrorAlertMinutes = 10 };
|
||||
await using var rig = await StartAsync(world, settings);
|
||||
rig.Monitor.EngineErrorRepeated += (_, _) => throw new ObjectDisposedException("Telegram");
|
||||
var one = new AuctionInfo("1") { Name = "Uno" };
|
||||
|
||||
// NoteEngineError si chiama dai catch del motore: non deve lanciare, e la riga resta nel registro.
|
||||
rig.Monitor.NoteEngineError(one, "Errore nel cecchino: prova", AuctionLogCategory.Bid);
|
||||
|
||||
Assert.Single(one.Log.Snapshot(), e => e.Level == LogLevel.Error);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Dopo_un_riavvio_ogni_asta_riprende_da_dove_era()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user