intro
« Previous section Next section »
UCloud Developer Guide / Developing UCloud / Micro Library Reference / RPC / Introduction
Introduction
Remote Procedure Call (RPC) interfaces define the interface a given micro-service exposes via the network. The interface describes how each call should be made on a concrete RPC backend. Each micro-service define the interfaces in the api
package. You can read more about the overall structure of a micro-service here.
⚠️WARNING: This document, while still true, has mostly been superseded by shorter versions for defining a call. These are described in more detail here.
The interfaces themselves are defined using a Kotlin DSL. If you are unfamiliar with the syntax it might help to read this article.
Example: Defining a remote procedure call (RPC) interface
Example: Calling a remote procedure call
Example: Adding a dependency on another service api
package
Anatomy of a remote procedure call
A remote procedure calls consists of two parts:
The header
The body
In the header we define the calls types. The system uses the types in serialization of the data as well as type-safety. The types themselves must also be stored in the api
component.
Figure: The remote procedure call header contains a name and three types associated with it (request, success, error).
In the body of the remote procedure call definition we place one or more blocks. Each block provides instructions to both the RPC client and the server. For example, the server uses this information to configure the underlying server implementation (e.g. Ktor) to listen on the correct endpoint. Similarly, the client uses this information to make the correct call on the network.
Figure: The body of an RPC contains several 'blocks'. Each block helps define how the client and server should treat these calls.
Reference
Block | Mandatory | Description |
---|---|---|
✅ Yes | Provides configuration for authentication and authorization | |
❌ No | The | |
❌ No |
| |
❌ No |
|
Note: Even though both http
and websocket
is optional you must select at least one. We recommend that you use http
for most calls.
Last updated