-
Notifications
You must be signed in to change notification settings - Fork 36
Open
Labels
featureNew feature or requestNew feature or request
Description
Is your feature request related to a problem? Please describe.
When registering rpc services, I can't make suspend calls.
Describe the solution you'd like
The code for registering rpc services is executing per connection thus KrpcRoute implements WebSocketSession. Why not just the block suspendable?
I traced the code and it appears that there is no issues with making it suspend other than changing the signature:
// ...
@KtorDsl
public fun Route.rpc(builder: KrpcRoute.() -> Unit) {
createRpcServer(builder)
}
private fun Route.createRpcServer(rpcRouteBuilder: KrpcRoute.() -> Unit) {
// ...
webSocket {
val rpcRoute = KrpcRoute(this).apply(rpcRouteBuilder)
// ...
}
}
Describe alternatives you've considered
- Copy-paste with signature change -> not effective
- Using call attributes -> too confusing and error prune
Additional context
I need it to be suspend to decode the access token which needs the keyset of the service which might not be in the cache.
morki
Metadata
Metadata
Assignees
Labels
featureNew feature or requestNew feature or request