Book Image

Scala Microservices

By : Selvam Palanimalai, Jatin Puri
Book Image

Scala Microservices

By: Selvam Palanimalai, Jatin Puri

Overview of this book

<p>In this book we will learn what it takes to build great applications using Microservices, the pitfalls associated with such a design and the techniques to avoid them. </p><p>We learn to build highly performant applications using Play Framework. You will understand the importance of writing code that is asynchronous and nonblocking and how Play leverages this paradigm for higher throughput. The book introduces Reactive Manifesto and uses Lagom Framework to implement the suggested paradigms. Lagom teaches us to: build applications that are scalable and resilient to failures, and solves problems faced with microservices like service gateway, service discovery, communication and so on. Message Passing is used as a means to achieve resilience and CQRS with Event Sourcing helps us in modelling data for highly interactive applications. </p><p>The book also shares effective development processes for large teams by using good version control workflow, continuous integration and deployment strategies. We introduce Docker containers and Kubernetes orchestrator. Finally, we look at end to end deployment of a set of scala microservices in kubernetes with load balancing, service discovery and rolling deployments. </p><p></p>
Table of Contents (12 chapters)

Brief introduction to Slick

There are numerous libraries to make SQL calls to database using JDBC, which is the gold standard on the JVM world to access relational databases. In this project, we have used the Slick library to access database.

Slick is like LINQ of the Microsoft world. It adheres to the Reactive Manifesto (http://www.reactivemanifesto.org/) (you will learn more about Reactive Manifesto in Chapter 5, Reactive Manifesto). Slick lets you access data from a relational database, and the experience is like dealing with collections rather than a database. We deal with tables as if they are collections in reality. Although, in the background, it auto-generates SQL queries.

For example, consider the following lines of code:

    val q = for {
user <- users if user.name == "***@gmail.com"
} yield (user.name, user.creationTime)

This will generate an SQL...