Skip to content

RPC in a single line of Scala code

Notifications You must be signed in to change notification settings

martin-ockajak/automorph

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 

Repository files navigation

Automorph

Documentation API Artifacts Scala License Build

Automorph is a Scala RPC client and server library for type-safely calling and serving remote APIs in a few lines of code.

The project repository has been moved here.

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")

// Register the API implementation to be available as a remote service
val apiServer = server.service(service)

// Create a type-safe local proxy for the remote API from an API trait
val remoteApi = client.proxy[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: Mundane parts of the code are omitted and can be found in the full example.

Links