Add server interceptor blending

This commit implements the `@GprcService(blendWithGlobalInterceptors)`
feature. This allows global and per-service server interceptors to be
combined into a single list and then finally sorted (i.e. blended).

Signed-off-by: Chris Bono <chris.bono@gmail.com>
This commit is contained in:
Chris Bono
2024-11-17 22:31:25 -06:00
committed by Dave Syer
parent e3d58cf988
commit 8eb623e82d
4 changed files with 46 additions and 3 deletions

View File

@@ -128,6 +128,16 @@ BindableService myService() {
}
----
[[server-interceptor-blending]]
[TIP]
====
When a service is configured with both global and per-service interceptors, the global interceptors are first applied in their sorted order followed by the per-service interceptors in their sorted order.
However, by setting the `blendWithGlobalInterceptors` attribute on the `@GrpcService` annotation to `"true"` you can change this behavior so that the interceptors are all combined and then sorted according to their bean natural ordering (i.e. `@Order`).
You can use this option if you want to add a per-service interceptor between global interceptors.
====
== Observability
Spring gRPC provides an autoconfigured interceptor that can be used to provide observability to your gRPC services.