This repository was archived by the owner on Mar 27, 2026. It is now read-only.
Allow adding custom gRPC interceptors when creating Modal clients#201
Merged
Allow adding custom gRPC interceptors when creating Modal clients#201
Conversation
thomasjpfan
reviewed
Nov 4, 2025
Contributor
thomasjpfan
left a comment
There was a problem hiding this comment.
Minor nits, but code-wise this looks good to me.
modal-go/client.go
Outdated
| sdkVersion: sdkVersion(), | ||
| logger: logger, | ||
| ipClients: make(map[string]pb.ModalClientClient), | ||
| customUnaryInterceptors: params.GRPCUnaryInterceptors, |
Contributor
There was a problem hiding this comment.
Nit in naming, but not blocking:
Suggested change
| customUnaryInterceptors: params.GRPCUnaryInterceptors, | |
| additionalUnaryInterceptors: params.GRPCUnaryInterceptors, |
In this context, these are just "more interceptors" to be appended to the rest of the interceptors
| retryInterceptor(c), | ||
| timeoutInterceptor(), | ||
| } | ||
| unaryInterceptors = append(unaryInterceptors, customUnaryInterceptors...) |
Contributor
There was a problem hiding this comment.
If one wants to write a tracer that is aware of our retry semantics, they would need to read the retryInterceptor code and also pass the metadata into their tracer.
Note, I'm okay with this.
Comment on lines
+53
to
+56
| mu.Lock() | ||
| firstCalled = true | ||
| firstMethod = method | ||
| mu.Unlock() |
Contributor
There was a problem hiding this comment.
Very very nit:
Suggested change
| mu.Lock() | |
| firstCalled = true | |
| firstMethod = method | |
| mu.Unlock() | |
| mu.Lock() | |
| defer mu.Unlock() | |
| firstCalled = true | |
| firstMethod = method |
(It's slightly different behavior from what you have, but using defer feels more "go like")
Comment on lines
+68
to
+71
| mu.Lock() | ||
| secondCalled = true | ||
| secondMethod = method | ||
| mu.Unlock() |
Contributor
There was a problem hiding this comment.
Suggested change
| mu.Lock() | |
| secondCalled = true | |
| secondMethod = method | |
| mu.Unlock() | |
| mu.Lock() | |
| defer mu.Unlock() | |
| secondCalled = true | |
| secondMethod = method |
thomasjpfan
approved these changes
Nov 4, 2025
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Note
Adds support to attach custom gRPC interceptors (Go) and middleware (JS) to Modal clients, applied after built-ins, with examples, tests, and docs updates.
modal-go):ClientParams.GRPCUnaryInterceptorsandClientParams.GRPCStreamInterceptors; store onClientand pass tonewClient(...).modal-js):ModalClientParams.grpcMiddleware; store and append to client factory after built-in middleware (auth, retry, timeout).modal-go/examples/telemetry/main.goandmodal-js/examples/telemetry.ts.modal-go/client_test.go,modal-js/test/client.test.ts.CHANGELOG.mdwith unreleased note.Written by Cursor Bugbot for commit 2c7d4e0. This will update automatically on new commits. Configure here.