Endpoints

A Quest for the Right Level of Coupling

http://julienrf.github.io/2019/endpoints

Agenda

 

bestmile sponsor

1 Motivation

1.1 Context

Monolith

Monolith: Pros & Cons

Pros

Cons

Distributed

Distributed: Pros

Distributed: Cons

Crossing Program Boundaries

1.2 How Do We Cross Program Boundaries in Practice?

Java RMI

val b: B = service.compute(a)

Java RMI: Cons

Illusion of Transparency

“Distribution transparency is impossible to achieve in practice. Precisely because of that impossibility, it is dangerous to provide the illusion of transparency”. Rachid Guerraoui et al., 1999

Akka

import akka.actor.typed.scaladsl.AskPattern._

val eventualB: Future[B] = serviceRef.ask(ref => Compute(a, ref))

Akka: Cons

HTTP Services

val eventualB: Future[B] =
  httpClient.post("http://service/compute", a.toJson)
    .filter(_.status == 200)
    .flatMap(_.entity.asJson.to[B])

HTTP Services: Cons

WSDL

val eventualB: Future[B] = service.compute(a)

(assuming that you have generated service implementation class with a tool like scalaxb)

WSDL: Cons

gRPC

Meta-Programming

Idea: mitigate code generation issues by synthesizing code with macros instead

trait Service {
  def compute(a: A): B
}

val service = synthesized.Client[Service]
val eventualB: Future[B] = service.compute(a)

Meta-Programming: Cons

2 Demo

3 Design

Just a Boring Library

First-Class Scala Values

No Macros

Modularity

Modularity²

Extensibility

4 The End

Thanks for your attention

Any questions?