Support callable ingress_headers for per-request context propagation#11
Merged
Merged
Conversation
…ntext Allow Config#ingress_headers and #admin_headers to accept a callable (Proc/Lambda/any #call responder) in addition to a static Hash. The callable is evaluated each time Restate.client is built, enabling frameworks like Rails to inject per-request context headers (team ID, shard routing, auth tokens) that vary by caller context. Co-authored-by: Cursor <cursoragent@cursor.com>
igalshilman
approved these changes
May 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Allow
Config#ingress_headersand#admin_headersto accept a callable (Proc,Lambda, or any object responding to#call) in addition to a staticHash. The callable is evaluated each timeRestate.clientis built.Motivation
Frameworks like Rails need to inject per-request headers (team context, shard routing, auth tokens) that vary by caller context. A static Hash configured at boot time can't capture this. A callable evaluated at
Restate.clientcall time solves this cleanly:Changes
lib/restate.rb—Restate.clientnow callsresolve_headerswhich invokes.callon callable values, or passes Hashes through unchanged.lib/restate/config.rb— Updated RDoc oningress_headersandadmin_headersto document the callable option with examples.spec/callable_headers_spec.rb— 8 new tests covering: static Hash passthrough, lambda/Proc evaluation perclientcall, fresh evaluation on each call, mixed static+callable, and arbitrary#callresponders.spec/introspection_spec.rb— Updated the test-localRestate.clientstub to use the same resolution logic.Backward Compatibility
Fully backward compatible — existing static Hash configs continue to work unchanged. The
respond_to?(:call)check only activates for callable values.Made with Cursor