Skip to content

SMOODEV-946: .NET parity sweep — builder, circuit breaker, hooks, OnRejection, FastFirst#75

Merged
brentrager merged 1 commit into
mainfrom
SMOODEV-946-dotnet-parity
May 12, 2026
Merged

SMOODEV-946: .NET parity sweep — builder, circuit breaker, hooks, OnRejection, FastFirst#75
brentrager merged 1 commit into
mainfrom
SMOODEV-946-dotnet-parity

Conversation

@brentrager
Copy link
Copy Markdown
Contributor

Summary

Closes the biggest parity gap in the .NET port:

  • SmooFetchBuilder fluent API (SmooFetchBuilder.Create().With...().Build()).
  • Polly-based circuit breaker composed inside the resilience pipeline (WithCircuitBreaker(failureThreshold, openDuration)).
  • Lifecycle hooksPreRequest, PostRequestOk, PostRequestErr.
  • OnRejection callback with OnRejectionDecision discriminated union (Retry / RetryWithDelay(delay) / Abort / Skip / Default) honored by the Polly DelayGenerator.
  • FastFirst on RetryPolicy — first retry fires with zero delay.

Existing SmooFetchOptions + SmooFetch.Create factory remain backwards-compatible — everything new is additive. RetryPolicy is now a record so builder methods can use with to layer overrides.

Also includes a one-line #[allow(dead_code)] on TestReply in the Rust auth_provider_tests.rs added in #72 — the struct is a serde-only target so cargo errors under -D warnings without the annotation.

Out of scope (follow-up)

Sliding-window rate limiter for .NET. The ticket explicitly called out that this could ship as a follow-up "if context is tight"; FastFirst is included here, leaving rate limiter as the only remaining gap.

Test plan

  • dotnet build — clean (3 frameworks)
  • dotnet test — 27 passed (7 new builder cases)

…ejection, FastFirst

Brings the .NET port closer to feature parity with the TS / Python / Rust /
Go ports. Existing `SmooFetchOptions` + `SmooFetch.Create` factory remain
for backwards compatibility — everything new is additive.

New surface
-----------
- `SmooFetchBuilder` (`SmooFetchBuilder.Create().With...().Build()`).
- `LifecycleHooks` with `PreRequest`, `PostRequestOk`, `PostRequestErr`.
- `CircuitBreakerOptions` + Polly v8 circuit breaker composed inside the
  resilience pipeline. Trips on the same predicates as the retry policy.
- `OnRejectionCallback` / `OnRejectionDecision` (`Retry` / `RetryWithDelay` /
  `Abort` / `Skip` / `Default`) honored by the Polly `DelayGenerator`.
- `RetryPolicy.FastFirst` — first retry fires with zero delay.
- `RetryPolicy` converted to `record` so builder methods can use `with` to
  compose policies on the fly.

Tests
-----
New `SmooFetchBuilderTests` (7 cases) cover the builder happy path,
PreRequest / PostRequestOk hook firing, the PostRequestErr documented
behavior (only fires on transport-level throws, not HttpResponseError from
the JSON reader), FastFirst skipping the initial backoff, OnRejection
RetryWithDelay overriding the default delay, and the circuit breaker
tripping after the failure threshold.

Also included
-------------
- `#[allow(dead_code)]` on `TestReply` in the Rust `auth_provider_tests.rs`
  added in PR #72 — the struct is only used as a `serde` deserialization
  target so cargo errors under `-D warnings` without the annotation.

Out of scope (parked as follow-up)
----------------------------------
- Sliding-window rate limiter for .NET (callout from SMOODEV-946: "Rate
  limiter and FastFirst can ship as a follow-up if context is tight" —
  FastFirst is included; rate limiter is the only remaining gap).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@brentrager brentrager merged commit 62e0c22 into main May 12, 2026
1 check passed
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 12, 2026

🦋 Changeset detected

Latest commit: 6bf9aaf

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@smooai/fetch Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@brentrager brentrager deleted the SMOODEV-946-dotnet-parity branch May 12, 2026 17:29
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