GRPC-Kotlin-Multiplatform
GRPC-Kotlin-Multiplatform copied to clipboard
KMStub with stream RPC calls are also marked as suspend ?
public expect class KMWorkspaceServiceStub private constructor() : KMStub<KMWorkspaceServiceStub> {
public constructor(channel: KMChannel)
public suspend fun getWorkspaces(request: KMEmpty, metadata: KMMetadata = KMMetadata()):
Flow<KMSKWorkspaces>
public suspend fun saveWorkspace(request: KMSKWorkspace, metadata: KMMetadata = KMMetadata()):
KMSKWorkspace
}
Please check the generated code, the **getWorkspaces**
method returns a Flow, so it should not be a suspend method.
In JVMServiceWrite it should be
if (!rpc.isResponseStream) {
beginControlFlow(
"return %M",
MemberName("io.github.timortel.kotlin_multiplatform_grpc_lib.rpc", "simpleCallImplementation")
)
} else {
beginControlFlow(
"return %M",
MemberName("io.github.timortel.kotlin_multiplatform_grpc_lib.rpc", "simpleNonSuspendingCallImplementation")
)
}
fun <COMMON_RESPONSE> simpleNonSuspendingCallImplementation(
performCall: () -> COMMON_RESPONSE
): COMMON_RESPONSE {
return try {
performCall()
} catch (e: StatusException) {
throw KMStatusException(KMStatus(KMCode.getCodeForValue(e.status.code.value()), e.status.description.orEmpty()), e)
}
}
Yes, the suspend is indeed not necessary. I will look into removing suspend from the server-side streaming functions. Thank you for the suggestion.
This should be fixed in 0.3.0