feat(client): distinguish discovery failures and configure endpoint budgets - #4959
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 27226f92d3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if errors.Is(cause, selector.ErrNotFound) || errors.Is(cause, registry.ErrNotFound) { | ||
| code = 404 |
There was a problem hiding this comment.
Preserve unavailable errors across cache throttling
With the default registry selector, an initial backend outage records lastRefreshAttempt, and a subsequent lookup without cached data during the five-second retry interval returns the synthetic registry.ErrNotFound from registry/cache/cache.go:209. This branch consequently maps repeated requests during the same outage to 404 even though the first request correctly returned 503, defeating the new missing-versus-unavailable distinction. Preserve the last backend error through the cache throttle or otherwise avoid classifying this synthetic not-found as a missing service.
Useful? React with 👍 / 👎.
| if value := ctx.String("client_connection_timeout"); value != "" { | ||
| duration, err := time.ParseDuration(value) | ||
| if err != nil { | ||
| return fmt.Errorf("failed to parse client_connection_timeout: %w", err) | ||
| } | ||
| clientOpts = append(clientOpts, client.ConnectionTimeout(duration)) |
There was a problem hiding this comment.
Apply connection timeouts in the native gRPC client
When MICRO_CLIENT=grpc, the new MICRO_CLIENT_CONNECTION_TIMEOUT setting is stored in CallOptions.ConnectionTimeout, but the native gRPC call path never reads that field; it only applies DialTimeout while obtaining a connection and the total RequestTimeout around the call. Consequently this advertised request-attempt budget is a silent no-op for gRPC, so one slow attempt can consume the entire request budget and prevent useful retries. The gRPC call path should enforce ConnectionTimeout per attempt, or the setting must be scoped so it is not advertised for that client.
Useful? React with 👍 / 👎.
Missing services and unavailable discovery currently both surface as opaque 500s, and slow endpoints require timeout overrides at every call site.
Add typed client.DiscoveryError with preserved backend causes, registry.ErrUnavailable for NATS outages, and client.ErrNoNodes. Map missing services to 404 and unavailable selection to 503. Add per-service/endpoint CallOption defaults for RPC and native gRPC clients; explicit call options win. Enforce the earlier of configured request budget and caller deadline. Add the connection-timeout environment/CLI setting and correct request-timeout help text.
Validation: option precedence/isolation, typed discovery status/cause, both clients' deadline handling and local NATS disconnection tests pass. Build and lint pass. Full CI validates compatibility.
Closes #4939