Need to verify a small PR in a service that sends heartbeats by a list of job identifiers and returns an execution summary. After the changes, complaints appeared: request cancellation sometimes does not stop processing in time, and with repeated identifiers in a single call the final summary no longer matches the contract.
SendAsync method accepts a jobIds set and a CancellationToken.jobId within a single call must also be counted as skipped.Sent field must reflect the number of heartbeat messages actually sent.Skipped field must reflect the number of input elements that were not sent because of an empty value or a duplicate within the current call.OperationCanceledException.HeartbeatBatchSender.SendAsync with the following list:
"job-1"" ""job-1""job-2"SendAsync with several valid jobId values and cancel the token while waiting between elements.Example call:
var sender = new HeartbeatBatchSender();
var summary = await sender.SendAsync(new[] { "job-1", " ", "job-1", "job-2" }, CancellationToken.None);
job-1 and job-2.Skipped should include both the whitespace value and the repeated job-1..NET 8.0C# 12Task, CancellationToken, Task.DelayHeartbeatBatchSender.SendAsync(...) from a test or console applicationUse line comments to explain the problem, its impact, the fix and how to test it.