Dynamic handler loading in @effect/rpc - recommended approach? #5867
Unanswered
schickling
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Context
I'm exploring whether it's possible to dynamically load more handlers into a running
@effect/rpcserver. My use case involves adding new RPC handlers at runtime without restarting the server.Investigation Findings
After exploring the codebase, I found that dynamic handler loading is not currently supported out of the box. Here's what I discovered:
Current Architecture
readonly requests: ReadonlyMap<string, R>Potential Approaches I've Identified
1. ResourceRef Pattern (from @effect/cluster)
I noticed that
@effect/clusteruses aResourceRefpattern inentityManager.tsthat allows hot-swapping RPC servers:This seems like the most proven approach since it's already in production use.
2. Layer Reconstruction
Reconstruct the entire server with updated handler layers. Maintains type safety but requires connection draining.
3. Proxy Handler Pattern
Use a single dispatch handler that routes to dynamically registered implementations. Works with current design but loses RPC type safety.
Questions
@effect/rpc?Any guidance would be greatly appreciated!
This discussion was created with assistance from Claude Code
Beta Was this translation helpful? Give feedback.
All reactions