Skip to content

Commit e1ec7eb

Browse files
docs(audience-http): plain-language comment pass
Rewrites jargon (2xx server acked, serialise, diagnostic must not block the success path) into plain language. No code changes. All 184 tests pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 9fec2fb commit e1ec7eb

2 files changed

Lines changed: 11 additions & 10 deletions

File tree

src/Packages/Audience/Runtime/ImmutableAudience.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -555,10 +555,10 @@ public static async Task FlushAsync(CancellationToken cancellationToken = defaul
555555

556556
queue.FlushSync();
557557

558-
// Serialise SendBatchAsync via _sendInFlight. Without the gate,
559-
// two concurrent FlushAsync callers both call ReadBatch with the
560-
// same paths and double-POST. Poll cheaply while another caller
561-
// (timer SendBatch or a racing FlushAsync) holds the gate.
558+
// Only one send runs at a time. Without this, two FlushAsync
559+
// callers would both read the same batch from disk and send it
560+
// twice. Yield while another caller (the timer or another
561+
// FlushAsync) holds the in-flight slot.
562562
while (Interlocked.CompareExchange(ref _sendInFlight, 1, 0) != 0)
563563
{
564564
cancellationToken.ThrowIfCancellationRequested();

src/Packages/Audience/Runtime/Transport/HttpTransport.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,10 @@ internal async Task<bool> SendBatchAsync(CancellationToken ct = default)
9999

100100
if (statusCode >= 200 && statusCode < 300)
101101
{
102-
// 2xx: server acked. Parse {accepted, rejected} and surface
103-
// any partial rejections via onError — rejected events are
104-
// validation errors, won't succeed on retry.
102+
// Server accepted the batch. Count how many messages it
103+
// rejected; if any, tell the studio via onError. Rejected
104+
// messages are validation failures — retrying won't help,
105+
// so the batch is deleted either way.
105106
var rejected = await ParseRejectedCount(response).ConfigureAwait(false);
106107
_store.Delete(batch);
107108
ResetBackoff();
@@ -233,9 +234,9 @@ private void ResetBackoff()
233234
return sb.ToString();
234235
}
235236

236-
// Reads the body and extracts "rejected". Returns 0 on any parse or
237-
// read failure — the body is diagnostic, so a malformed one must not
238-
// block the success path.
237+
// Reads the response body and pulls out the "rejected" count. Returns
238+
// 0 if the body is missing or unreadable — the body is only for
239+
// reporting, so failing to read it must not break the success path.
239240
private static async Task<int> ParseRejectedCount(HttpResponseMessage response)
240241
{
241242
string body;

0 commit comments

Comments
 (0)