Skip to content

Warning-free build, cacheability refactor, and real-world sample (API + Redis + Polly) - #4

Merged
FranRuiz98 merged 2 commits into
masterfrom
test/resolve-xunit-analyzer-warnings
Jul 23, 2026
Merged

Warning-free build, cacheability refactor, and real-world sample (API + Redis + Polly)#4
FranRuiz98 merged 2 commits into
masterfrom
test/resolve-xunit-analyzer-warnings

Conversation

@FranRuiz98

Copy link
Copy Markdown
Owner

What

Three independent pieces of housekeeping and developer experience:

  1. Warning-free build (25b1621): resolves every xUnit analyzer warning in the test project (xUnit1051: use TestContext.Current.CancellationToken). The full solution now builds with 0 warnings, matching the repo's contribution rule.
  2. Refactor: converts the cacheability status-code switch statement in CachingMiddleware to a switch expression. No behavior change — same status codes, same explicit-freshness guard for 404/405/410/414.
  3. Real-world sample (samples/): a runnable deployment proving the full recommended pipeline against real infrastructure — Kestrel origin API + Redis-backed DistributedCacheStore + Polly (retry with exponential backoff + timeout) chained below the coalescer, orchestrated with docker-compose running two client replicas.

Why

  • The analyzer warnings were the last noise in an otherwise zero-warning build.
  • The demo project uses a fake in-process handler by design; the sample fills the gap it can't: real network, real ASP.NET-generated headers, real Redis serialization, and the multi-instance story (cache shared via Redis, coalescing per-process — documented explicitly in samples/README.md).

Reviewer notes

  • Samples are intentionally NOT in Stampede.Http.slnx, so CI and the normal dev loop stay Docker-free. They reference the library by ProjectReference, so they always exercise current source.
  • Validated end-to-end locally (real Kestrel + Redis container + two client instances): coalescing collapsed a 10-caller burst to 1 origin call (coalescing.deduplicated = 9), sub-millisecond Redis hits with Age, 304 conditional revalidation on expiry, stale-while-revalidate background refresh, Polly retries visible on 503 bursts, and a POST /catalog invalidation observed by both client instances through the shared store.
  • The docker compose up --build image builds themselves were not exercised (only local dotnet run + a Redis container); a root .dockerignore is included to keep bin/obj out of the build context.
  • Found during sample validation, out of scope here: after a 304 revalidation the Age header keeps growing instead of resetting (RFC 9111 §4.3.4 / §4.2.3). Tracked as a follow-up task.

Test plan

  • dotnet build Stampede.Http.slnx -c Release → 0 warnings, 0 errors
  • dotnet test Stampede.Http.Tests -c Release → 343/343 passing
  • Manual e2e of the sample as described above

🤖 Generated with Claude Code

FranRuiz98 and others added 2 commits July 23, 2026 21:35
…expression

No behavior change — same status codes, same explicit-freshness guard for
404/405/410/414.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…-compose

Adds samples/ with a Kestrel origin API that drives caching purely through
standard headers (Cache-Control, ETag, Vary, stale windows) and a client
wiring the full recommended pipeline: AddStampedeHttp +
UseDistributedCacheStore (Redis) + Polly resilience handler (retry with
exponential backoff + timeout) chained below the coalescer.

docker-compose runs Redis + the API + two client replicas to demonstrate
the Redis-backed cache being shared across instances while coalescing
stays per-process. Includes an outage drill (stop the API, watch
stale-if-error shield callers) and a samples README documenting what to
watch. Samples are intentionally not part of Stampede.Http.slnx so the
main build and CI stay Docker-free.

Validated end-to-end locally against real Kestrel + Redis: coalescing
10 -> 1, sub-millisecond Redis hits with Age, 304 revalidation, SWR
background refresh, Polly retries on 503 bursts, POST invalidation
shared across two client instances.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@FranRuiz98
FranRuiz98 merged commit b8b30aa into master Jul 23, 2026
2 checks passed
@FranRuiz98
FranRuiz98 deleted the test/resolve-xunit-analyzer-warnings branch July 23, 2026 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant