Automorph

Documentation API Artifacts Scala License Build

Automorph is a Scala RPC client and server library for invoking and exposing remote APIs in a few lines of code.

Features

Example

// Define a remote API
trait Api:
  def hello(n: Int): Future[String]

// Create server implementation of the remote API
val service = new Api:
  def hello(n: Int): Future[String] =
    Future(s"Hello world $n")

// Expose a server API implementation to be called remotely
val apiServer = server.bind(service)

// Create a type-safe local proxy for the remote API from an API trait
val remoteApi = client.bind[Api]

// Call the remote API function via the local proxy
remoteApi.hello(1)

// Call the remote API function dynamically without using the API trait
client.call[String]("hello")("n" -> 1)

Note: Imports, server setup and client setup are omitted here and can be found in the full example.

Links