Akka Services
Summary
This is a study project for playing with Akka ecosystem:
Project Description
Structure
This project applies extensively the (Thin) Cake Pattern:
// launches a HTTP server
object Main extends App with Services
// initializes the actors system
trait Services extends Config with Routes
// loads configuration parameters (e.g. HTTP interface and port, eventually DB connection settings...)
trait Config
// provides the routes directives (very similar to the ones from Spray)
trait Routes extends ErrorHandler with SysRoute with UserRoute with UrlRoute with StocksRoute
trait ErrorHandler
trait SysRoute extends DefaultJsonProtocol with SprayJsonSupport // system functions
trait UserRoute extends DefaultJsonProtocol with SprayJsonSupport
trait UrlRoute // simple URL shortener
trait StocksRoute // stocks info
// provide the domain objects, later marshalled / unmarshalled thanks to the JSON Support from Akka HTTP Spray Json
case class SimpleMessage // used in SysRoute
case class User // used in UserRoute
How to Run
- Clone the project:
git clone [email protected]:flopezlasanta/akka-services.git
- Compile the code, generate a Docker image and publish locally:
$ sbt docker:publishLocal
- Run the container
akka-services
together withredis
via Docker Compose:$ docker-compose up -d
- Test with the different end points (see next section)
- Stop the containers via Docker Compose:
$ docker-compose stop
How to Test
Note: when using VM / Docker Machine (this is my case) then use its corresponding IP address; otherwise localhost.
- Check system health:
curl -X GET http://192.168.99.100:9000/sys/health | jq .
- Ping system:
curl -X GET http://192.168.99.100:9000/sys/ping | jq .
- ...
Also in root there will be simple website (made with Bootstrap 3) listing all endpoints: