- Read Tutorial
This is going to be a fun course, if you've never built a microservice before you're in for a treat and you'll learn some important Ruby on Rails skills. So what type of application are we going to build? At a high level we're going to create a Rails microservice based app that will send notification text messages each time a new record is created.
Sounds pretty straightforward, right? That's really the point. Microservices, also referred to as Service Oriented Architecture (SOA) applications, should adhere to the following guidelines:
Only have one primary job - in the case of our application the job will be managing an alert system for sending text messages.
Be highly decoupled from other applications - essentially this means that the microservice app should maintain a level of abstraction from the applications that connect to it. For example, our alert sending microservice shouldn't be affected by regular changes to the front end application that will communicating with it. This separation of concerns gives flexibility to the developers working on the connected apps since they don't have to worry about breaking the alert sending functionality. The only change that should affect the alert sending feature is a change to the API call from the front end application.
The primary mindset you should have while building a microservice is that the application should be completely self contained. Imagine if you were the developer for the Google Maps API. Would you build the API method calls for a single application to connect to it? Let's hope not, you would build the system knowing that it had to be flexible enough for millions of apps to communicate with it. If we build our application properly it should be able to be used by other applications. For example, the initial application that will be communicating with our app will be a blogging comment system, however if we want to have users notified every time a new blog post is published our Post
app should be able to call our new microservice the same way that the comment system does.
Functional Requirements
Below are the core features that our application will entail:
notification
should be able to be created via a RESTful APIPOST
requestThe
Notification
model should have the attributes of:phone:string
,body:text
,source_app:string
notifications
should be available to be queried via the APInotifications
should have a default scope for thesource_app
Now that we know what we're going to build, the next few guides will step back and discuss the key topics in regard to microservice based applications.