You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is related to #75.
After hacking a way a bit trying to adapt kotlinx-rpc to a serverless architecture, I hit an issue.
To illustrate the problem, lets review the architecture of serverless computing.
However, krpc assumes the traditional dedicated server architecture:
As such, there is no way to know whether to enter the last step in the first diagram, and shut down the machine, outside of trying to parse the value, or counting the amount of sent messages, which is very fragile.
Proposed solution
Add a terminateProcedureCall() method to KrpcTransport / KrpcServer
public abstract class KrpcServer {
+ /**+ * Notifies that a unit of work has been done, and resources associated with this transport may be safely released. + * Implementation may safely ignore this method if they wish to reuse the same resources for multiple units of work (multiple procedure calls). + */+ public open suspend fun terminateProcedureCall(): Unit {}
}
Or alternatively:
public interface KrpcTransport : CoroutineScope {
public suspend fun send(message: KrpcTransportMessage)
public suspend fun receive(): KrpcTransportMessage
+ public suspend fun terminateProcedureCall(): Unit {}
public suspend fun receiveCatching(): Result<KrpcTransportMessage> {
return runCatching { receive() }
}
}
The text was updated successfully, but these errors were encountered:
natanfudge
changed the title
Provide some way for a KrpcTransport implementation to know if a procedure call is done
Provide some way for a KrpcTransport/KrpcServer implementation to know if a procedure call is done
Feb 17, 2025
Hey @natanfudge ! Thanks for the interest in the lib!
I have a question: I'm not sure I understand, whenterminateProcedureCall is intended to be called?
Uh oh!
There was an error while loading. Please reload this page.
This is related to #75.
After hacking a way a bit trying to adapt
kotlinx-rpc
to a serverless architecture, I hit an issue.To illustrate the problem, lets review the architecture of serverless computing.
However, krpc assumes the traditional dedicated server architecture:
If we look at the
KrpcTransport
interface:KrpcTransportMessage
only encodes the messages itself, and not whether this is the last message.As such, there is no way to know whether to enter the last step in the first diagram, and shut down the machine, outside of trying to parse the
value
, or counting the amount of sent messages, which is very fragile.Proposed solution
Add a
terminateProcedureCall()
method toKrpcTransport
/KrpcServer
Or alternatively:
public interface KrpcTransport : CoroutineScope { public suspend fun send(message: KrpcTransportMessage) public suspend fun receive(): KrpcTransportMessage + public suspend fun terminateProcedureCall(): Unit {} public suspend fun receiveCatching(): Result<KrpcTransportMessage> { return runCatching { receive() } } }
The text was updated successfully, but these errors were encountered: