Skip to content

feat: add DefaultTimeoutInterceptor#37

Merged
ankurs merged 3 commits intomainfrom
feat/default-timeout-interceptor
Apr 8, 2026
Merged

feat: add DefaultTimeoutInterceptor#37
ankurs merged 3 commits intomainfrom
feat/default-timeout-interceptor

Conversation

@ankurs
Copy link
Copy Markdown
Member

@ankurs ankurs commented Apr 8, 2026

Summary

  • Adds DefaultTimeoutInterceptor — applies a 60s default deadline to incoming unary gRPC requests that arrive without one
  • Requests with an existing deadline (shorter or longer) are left unchanged
  • Inserted as first ColdBrew interceptor in the default chain, before ResponseTimeLoggingInterceptor
  • SetDefaultTimeout(d) setter for programmatic config; 0 disables (pass-through)
  • Protects both direct gRPC and HTTP gateway paths (gateway disables Hystrix and sets no deadline today)

Test plan

  • TestDefaultTimeoutInterceptor_AppliesTimeout — no deadline → handler sees ~60s deadline
  • TestDefaultTimeoutInterceptor_ExistingDeadline — caller's deadline preserved
  • TestDefaultTimeoutInterceptor_DisabledSetDefaultTimeout(0) → no deadline added
  • TestDefaultInterceptors_IncludesTimeout — first CB interceptor sets deadline
  • make test passes with -race
  • make lint clean (0 issues, no vulnerabilities)

Adds a unary server interceptor that applies a configurable default
deadline (60s) to incoming gRPC requests that arrive without one.
Requests with an existing deadline are left unchanged. The interceptor
is inserted as the first ColdBrew interceptor in the default chain,
before ResponseTimeLoggingInterceptor.

- SetDefaultTimeout(d) setter for programmatic config
- 0 disables the interceptor (pass-through)
- 4 new tests covering: applies timeout, existing deadline preserved,
  disabled mode, chain inclusion
Copilot AI review requested due to automatic review settings April 8, 2026 06:13
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 8, 2026

Warning

Rate limit exceeded

@ankurs has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 7 minutes and 17 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 7 minutes and 17 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a0e2869e-453c-4772-90ff-cbbe2c4a2504

📥 Commits

Reviewing files that changed from the base of the PR and between 6403d6e and 0b5965c.

📒 Files selected for processing (4)
  • README.md
  • go.mod
  • interceptors.go
  • interceptors_test.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/default-timeout-interceptor

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new unary server interceptor to enforce a default deadline for inbound gRPC calls that arrive without one, improving safety for gRPC-gateway/HTTP->gRPC paths that currently don’t set deadlines.

Changes:

  • Introduces DefaultTimeoutInterceptor() which applies a configurable default timeout (60s by default) only when the incoming context has no deadline.
  • Adds SetDefaultTimeout(time.Duration) to configure/disable the behavior (0 disables).
  • Wires the interceptor into DefaultInterceptors() and adds unit tests covering behavior and chain placement; updates generated README docs.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
README.md Documents the new interceptor and setter in the generated API reference.
interceptors.go Adds global defaultTimeout, setter, new interceptor, and inserts it into the default unary interceptor chain.
interceptors_test.go Adds tests for default-timeout application, preservation of existing deadlines, disable behavior, and inclusion in the default chain.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

ankurs added a commit to go-coldbrew/core that referenced this pull request Apr 8, 2026
Adds config field and wiring for the DefaultTimeoutInterceptor
introduced in interceptors. The env var defaults to 60 seconds;
set to 0 to disable.

Depends on go-coldbrew/interceptors#37.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread interceptors.go
Comment thread go.mod
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread interceptors.go
@ankurs ankurs merged commit 96d0dda into main Apr 8, 2026
11 checks passed
@ankurs ankurs deleted the feat/default-timeout-interceptor branch April 8, 2026 07:35
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.

2 participants