perf(store-and-forward): bound retry sweep with SweepBatchLimit (default 500) on the due-rows query
This commit is contained in:
@@ -34,4 +34,8 @@ public class StoreAndForwardOptionsTests
|
||||
Assert.Equal(TimeSpan.FromMinutes(5), options.DefaultRetryInterval);
|
||||
Assert.Equal(100, options.DefaultMaxRetries);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SweepBatchLimit_Defaults_To_500() =>
|
||||
Assert.Equal(500, new StoreAndForwardOptions().SweepBatchLimit);
|
||||
}
|
||||
|
||||
@@ -587,6 +587,33 @@ public class StoreAndForwardStorageTests : IAsyncLifetime, IDisposable
|
||||
Assert.Null(retrieved!.ParentExecutionId);
|
||||
}
|
||||
|
||||
// ── Task 7 (arch review 02, Performance): bounded due-rows query ──
|
||||
|
||||
[Fact]
|
||||
public async Task GetMessagesForRetry_HonorsLimit_OldestFirst()
|
||||
{
|
||||
var baseTime = DateTimeOffset.UtcNow.AddMinutes(-10);
|
||||
for (var i = 0; i < 5; i++)
|
||||
{
|
||||
await _storage.EnqueueAsync(new StoreAndForwardMessage
|
||||
{
|
||||
Id = $"m{i}",
|
||||
Category = StoreAndForwardCategory.ExternalSystem,
|
||||
Target = "t",
|
||||
PayloadJson = "{}",
|
||||
RetryCount = 0,
|
||||
MaxRetries = 50,
|
||||
RetryIntervalMs = 0, // always due
|
||||
CreatedAt = baseTime.AddSeconds(i),
|
||||
Status = StoreAndForwardMessageStatus.Pending
|
||||
});
|
||||
}
|
||||
|
||||
var page = await _storage.GetMessagesForRetryAsync(limit: 3);
|
||||
Assert.Equal(3, page.Count);
|
||||
Assert.Equal(new[] { "m0", "m1", "m2" }, page.Select(m => m.Id));
|
||||
}
|
||||
|
||||
private static StoreAndForwardMessage CreateMessage(string id, StoreAndForwardCategory category)
|
||||
{
|
||||
return new StoreAndForwardMessage
|
||||
|
||||
Reference in New Issue
Block a user