Skip to content

Wire config.resilience to translator#11

Merged
jserv merged 1 commit intomainfrom
resilience
Feb 11, 2026
Merged

Wire config.resilience to translator#11
jserv merged 1 commit intomainfrom
resilience

Conversation

@jserv
Copy link
Copy Markdown
Owner

@jserv jserv commented Feb 11, 2026

The resilience config (circuit breaker thresholds, HTTP timeouts, retry counts, backoff delays) was defined in ResilienceConfig but never wired to the translator -- all three OnceLock singletons used hardcoded defaults. Similarly, fallback_to_passthrough existed in config but was never checked; translation errors unconditionally returned the original text.

Fix both by:

  • Adding init_resilience() to seed OnceLock singletons (circuit breaker, rate limiter, HTTP client) with user config before the first request
  • Threading &ResilienceConfig through translate_with_chunking, translate_chunks, and google_translate_with_retry_config
  • Extracting build_http_client() as single source of truth for the reqwest::Client builder (eliminates duplicated chain)
  • Checking config.resilience.fallback_to_passthrough in main.rs error handler: true (default) returns original text, false exits with status 1
  • Guaranteeing at least one translation attempt even if max_retries is 0 (prevents u32 wrapping and zero-attempt failure)

The resilience config (circuit breaker thresholds, HTTP timeouts, retry
counts, backoff delays) was defined in ResilienceConfig but never wired
to the translator -- all three OnceLock singletons used hardcoded
defaults. Similarly, fallback_to_passthrough existed in config but was
never checked; translation errors unconditionally returned the original
text.

Fix both by:
- Adding init_resilience() to seed OnceLock singletons (circuit breaker,
  rate limiter, HTTP client) with user config before the first request
- Threading &ResilienceConfig through translate_with_chunking,
  translate_chunks, and google_translate_with_retry_config
- Extracting build_http_client() as single source of truth for the
  reqwest::Client builder (eliminates duplicated chain)
- Checking config.resilience.fallback_to_passthrough in main.rs error
  handler: true (default) returns original text, false exits with
  status 1
- Guaranteeing at least one translation attempt even if max_retries is 0
  (prevents u32 wrapping and zero-attempt failure)
@codecov
Copy link
Copy Markdown

codecov bot commented Feb 11, 2026

Codecov Report

❌ Patch coverage is 46.42857% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.16%. Comparing base (ab23e59) to head (cbc848f).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/translator.rs 46.42% 15 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #11      +/-   ##
==========================================
- Coverage   65.37%   65.16%   -0.22%     
==========================================
  Files          11       11              
  Lines         774      775       +1     
==========================================
- Hits          506      505       -1     
- Misses        268      270       +2     
Flag Coverage Δ
unittests 65.16% <46.42%> (-0.22%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/translator.rs 45.67% <46.42%> (-0.23%) ⬇️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jserv jserv merged commit f8132c6 into main Feb 11, 2026
7 checks passed
@jserv jserv deleted the resilience branch February 11, 2026 03:26
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