Correzioni della revisione (#47)
NoteEngineError si chiama dentro i catch del motore, compreso quello del thread dedicato del cecchino: se chi ascolta EngineErrorRepeated (Telegram, già rilasciato durante lo spegnimento) o il conteggio lanciavano, l'eccezione usciva dal catch, chiudeva il ciclo dell'asta senza una riga che lo dicesse e, sul thread, poteva terminare il processo. Ora conteggio, riga MOTORE e avviso stanno in un try come BidPlaced e AuctionCompleted; la riga dell'errore nel registro dell'asta resta fuori e si scrive sempre. Un test prova che un ascoltatore che lancia non ferma NoteEngineError. L'aggiornamento di docs/stato.md (punto 13) è lasciato a chi aggiorna i documenti di stato dopo il lavoro. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit d4699b6e0c6301f3f608e9251d6254082657e4e4)
This commit is contained in:
1 parent
2d74aed552
commit
213b18add9
2 files changed
+26
-4
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