Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do typesafe remote procedure call (RPC) in Kotlin?

Tags:

kotlin

rpc

When developing both the frontend and backend in Kotlin it's just weird that we have to bother with rest json apis to connect them. Ideal would be the ability to define an interface

interface Api {
    fun sum(x: Int, y: Int): Int
}

Implement it on the server side.

And on the client side be able to call it as easy as

val api = RPCMagic<Api>
val result: Future<Int> = api.sum(2, 2)

Much like scala autowire library does.

like image 945
Yaroslav Avatar asked Mar 30 '17 13:03

Yaroslav


People also ask

What is remote procedure call RPC service?

Remote Procedure Call is a software communication protocol that one program can use to request a service from a program located in another computer on a network without having to understand the network's details. RPC is used to call other processes on the remote systems like a local system.

How do I run an RPC?

The basic steps involved, for most RPC implementations, are as follows. Write the package definition file to define the software interface. Run the RPC compiler to produce the stub code. Link together the client modules (program, stub, RTS) to make the client module.

What is RPC example?

Other examples of the use of RPC in experiments at CERN include: remote monitoring program control, remote FASTBUS access, remote error logging, remote terminal interaction with processors in VMEbus, the submission of operating system commands from embedded microprocessors, and many less general functions.

What are the two types of RPC message?

The Remote Procedure Call (RPC) message protocol consists of two distinct structures: the call message and the reply message (see RPC Call Message and RPC Reply Message). A client makes a remote procedure call to a network server and receives a reply containing the results of the procedure's execution.


1 Answers

At this time Kotlin provides no functionality for this, but it's on our medium-term roadmap (after 1.2).

like image 195
yole Avatar answered Nov 14 '22 04:11

yole