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.
- Seamless - Generate type-safe RPC client or server bindings from existing public API methods at compile time.
- Flexible - Customize data serialization, remote API function names, RPC protocol errors and authentication.
- Modular - Freely combine RPC protocol, message format, transport protocol and effect handling layers.
- Permissive - Consume or create dynamic message payload and access or modify transport protocol metadata.
- Discoverable - Utilize discovery functions providing OpenRPC 1.3+ and OpenAPI 3.1+ schemas for exposed APIs.
- Compatible - Use with Scala 3.3+ or 2.13+ on JRE 11+ and easily integrate with various libraries using plugins.
- Standards - JSON-RPC, Web-RPC, HTTP, WebSocket, AMQP, JSON, MessagePack, Smile, CBOR, Ion.
- Integrations - STTP, Tapir, Undertow, Vert.x, Jetty, Finagle, Akka HTTP, Pekko HTTP, RabbitMQ, Circe, Jackson, weePickle, uPickle, Argonaut.
- Effects - Identity, Try, Future, ZIO, Monix, Cats Effect, Scalaz Effect.
// 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.