spring-projects / spring-projects/spring-grpc
Support for gRPC request-scoped Spring beans (equivalent to net.devh's @Scope("grpcRequest"))
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 413
- Forks
- 95
- Avg merge
- 4d 6h
- Merged PRs (30d)
- 2
Description
🧩 Feature Request
Background
When migrating from net.devh:grpc-server-spring-boot-starter to spring-grpc, one of the missing features is support for request-scoped Spring beans within a gRPC call.
In net.devh, this was provided via @Scope("grpcRequest") that activated a new scope for the duration of each gRPC call, allowing developers to inject @Scope("grpcRequest") beans that are created once per RPC and destroyed when the call completes.
A typical use case: injecting a per-request context object (e.g. authenticated principal, request metadata, tracing state) into multiple downstream components without passing it explicitly through method arguments.
Question
Is there a plan to support a similar mechanism in spring-grpc?
Possible approaches we can think of is a built-in @Scope("grpcRequest") / @RpcScope backed by a ServerInterceptor that manages the scope lifecycle per call.
If there are no plans, any guidance on the recommended approach for per-request state management in spring-grpc would be appreciated — ideally documented (e.g. in the reference docs or as a wiki entry) so that teams can implement their own solution without waiting for a potential future addition to the starter.
Context
spring-grpc version |
1.0.2 |
| Migrating from | net.devh:grpc-server-spring-boot-starter:3.1.0.RELEASE |
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the gRPC ServerInterceptor integration and Spring bean-scope lifecycle; the issue does not identify specific files or tests. Define whether the result should be built-in request-scoped beans or documented guidance for managing per-request state, and verify the scope lasts for one RPC and is cleaned up when it completes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- grpc, java, spring
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Needs clarification
- Newbie friendliness
- 38/100