Interceptors
The RoadRunner gRPC plugin supports custom unary interceptors in both v5.3.0 and v6.
Use an interceptor to add processing before or after an RPC call, such as:
request/response logging,
authentication checks,
rate limiting,
custom metrics.
Interceptor contract
Your plugin must implement this interface:
type Interceptor interface {
UnaryServerInterceptor() grpc.UnaryServerInterceptor
Name() string
}The Name() return value is used in the grpc.interceptors configuration list.
Configuration
Add interceptor names under the grpc.interceptors section:
Execution order
RoadRunner applies configured interceptors in the same order as the config list.
Example:
Execution order will be:
first -> second -> third -> handler
Build a custom binary
Include your interceptor plugin in a custom RR build. Use plugin versions compatible with v6. Listing an interceptor in .rr.yaml does not add its code to the binary.
For an interceptor that reads protobuf descriptors, see the registry-based example. Use the plugin's Name() in grpc.interceptors.
Run and verify
Start RoadRunner:
Send a request using your preferred gRPC client (for example, grpc-client-cli) and verify interceptor logs in RR output.
What's next?
Last updated