Skip to content

feat(client): distinguish discovery failures and configure endpoint budgets - #4959

Merged
asim merged 1 commit into
masterfrom
codex/4939-discovery-and-endpoint-options
Sep 21, 2026
Merged

asim merged 1 commit into
masterfrom
codex/4939-discovery-and-endpoint-options

Conversation

@asim

@asim asim commented Sep 21, 2026

Copy link
Copy Markdown
Member

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 21, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-21T07:41:32.282070Z 27226f9 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread client/discovery.go
Comment on lines +42 to +43
if errors.Is(cause, selector.ErrNotFound) || errors.Is(cause, registry.ErrNotFound) {
code = 404

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment thread cmd/cmd.go
Comment on lines +643 to +648
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))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@asim
asim merged commit 012cd36 into master Sep 21, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Client: registry/broker outage surfaces as "not found"; 5s defaults unsuited to slow RPCs

1 participant