MSocket is an opinionated library for building services in Scala and consuming them in Scala or Scala.js It abstracts over the underlying transport and ensures that swapping a transport layer does not require much code change. Right now it supports both requestResponse and requestStream protocols. In that sense it is heavily inspired from RSocket protocol which (no surprise) is available as one of the transports for MSocket. It has a dependency on wonderful 'borer' library for providing JSON and CBOR serialization of messages.
MSocket provides
- Multi-platform clients for JVM (Scala) as well as Javascript (Scala.js)
- Multi-lingual encoding for messages: Text (JSON) and Binary (CBOR)
- Multi-transport utilities for building and consuming services: Http, WebSocket and RSocket
- msocket-api: platform agnostic APIs that must be implemented by each services and their clients
- msocket-impl: Akka-Http based implementation of helpers utilities for service writers, and transport implementations for Http and Websocket
- msocket-impl-rsocket: RSocket-Java based implementation of helpers utilities for service writers, and transport implementation for RSocket
- msocket-impl-js: Scala.js transport implementation for Http, Websocket and RSocket
To show the capabilities of MSocket we have created an example implementation
in example-service
module with samples that caters to all the transport.
Specifically, it shows:
- how to structure the project modules (-api, -impl, -server, -app-jvm and -app-js)
- what are the dependencies of each of these modules
(among themselves and on MSocket modules) in the
build.sbt
- client-app wiring for each transport-platform-encoding combinations (-app-jvm and -app-js)
- sample API definitions and mechanical client derivation (-api)
- sample protocol messages and their borer based codecs (-api)
- sample API implementation (-impl)
- create a Service by defining Handlers and wiring with sample API implementation (-server)