Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions src/Netclaw.Actors/Jobs/BackgroundJobManagerActor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public sealed class BackgroundJobManagerActor : ReceiveActor
private readonly TimeProvider _timeProvider;
private readonly IOperationalNotificationSink _notificationSink;
private readonly ILoggingAdapter _log;
private bool _startupSchemaAlertsEmitted;

private readonly HashSet<string> _activeJobIds = [];
private readonly Queue<string> _deferredQueue = new();
Expand All @@ -60,14 +59,17 @@ public BackgroundJobManagerActor(
Receive<CancelBackgroundJob>(HandleCancel);
Receive<QueryBackgroundJob>(HandleQuery);
Receive<KillJobsForSession>(HandleKillJobsForSession);
Receive<Reconcile>(_ => HandleReconcile());
Receive<GetBackgroundJobManagerHealth>(_ => HandleGetHealth());
}

protected override void PreStart()
{
_log.Info("BackgroundJobManagerActor started");
Self.Tell(Reconcile.Instance);
// Run synchronously in PreStart so reconciliation completes before any
// user message is dispatched. A Self.Tell approach races on slow schedulers
// (macOS CI): ActorOf returns before PreStart executes, allowing external
// messages to queue ahead of the Reconcile message.
HandleReconcile();
}

private async Task HandleStartAsync(StartBackgroundJob cmd)
Expand Down Expand Up @@ -283,11 +285,7 @@ private void HandleGetHealth()
private void HandleReconcile()
{
var persisted = _store.List();
if (!_startupSchemaAlertsEmitted)
{
EmitRejectedLegacyDefinitionAlerts();
_startupSchemaAlertsEmitted = true;
}
EmitRejectedLegacyDefinitionAlerts();

var reconciled = 0;

Expand Down Expand Up @@ -497,8 +495,4 @@ private static string BuildResultContent(BackgroundJobCompleted completed, Backg
output + filePath;
}

private sealed record Reconcile : INoSerializationVerificationNeeded
{
public static readonly Reconcile Instance = new();
}
}
Loading