Colossus
The obligatory Hello-world Service:
object HelloWorld extends App {
implicit val actorSystem = ActorSystem()
implicit val ioSystem = IOSystem()
HttpServer.start("example-server", 9000) { initContext =>
new Initializer(initContext) {
override def onConnect: RequestHandlerFactory =
serverContext =>
new RequestHandler(serverContext) {
override def handle: PartialHandler[Http] = {
case request @ Get on Root => request.ok("Hello world!")
}
}
}
}
}
Colossus is a low-level event-based framework. In a nutshell, it spins up multiple event loops, generally one per CPU core. TCP connections are bound to event loops and request handlers (written by you) are attached to connections to transform incoming requests into responses. I/O operations (such as making requests to a remote cache or another service) can be done asynchronously and entirely within the event loop, eliminating the need for complex multi-threaded code and greatly reducing the overhead of asynchronous operations.
Source & Docs
The source code for this page can be found here.