MVC and CRUD make software easier to write, but harder to change. Microservice-based architectures can help even the smallest of projects remain agile in the long term, but most tutorials meander in theory or completely miss the point of what it means to be microservice-based. Roll up your sleeves with real projects and learn the most important concepts of evented architectures. You'll have your own deployable, testable project and a direction for where to go next.
Much ink has been spilled on the topic of microservices, but all of this writing fails to accurately identity what makes a system a monolith, define what microservices are, or give complete, practical examples, so you're probably left thinking they have nothing to offer you. You don't have to be at Google or Facebook scale to benefit from a microservice-based architecture. Microservices will keep even small and medium teams productive by keeping the pieces of your system focused and decoupled.
Discover the basics of message-based architectures, render the same state in different shapes to fit the task at hand, and learn what it is that makes something a monolith (it has nothing to do with how many machines you deploy to). Conserve resources by performing background jobs with microservices. Deploy specialized microservices for registration, authentication, payment processing, e-mail, and more. Tune your services by defining appropriate service boundaries. Deploy your services effectively for continuous integration. Master debugging techniques that work across different services. You'll finish with a deployable system and skills you can apply to your current project.
Add the responsiveness and flexibility of microservices to your project, no matter what the size or complexity.
What You Need:
While the principles of this book transcend programming language, the code examples are in Node.js because JavaScript, for better or worse, is widely read. You'll use PostgreSQL for data storage, so familiarity with it is a plus. The books does provide Docker images to make working with PostgreSQL a bit easier, but extensive Docker knowledge is not required.
Author(s): Ethan Garofolo
Edition: 1
Publisher: Pragmatic Bookshelf
Year: 2020
Language: English
Commentary: Vector PDF
Pages: 292
City: Raleigh, NC
Tags: Debugging; JavaScript; Concurrency; Relational Databases; PostgreSQL; Messages; Microservices; Docker; Node.js; Software Architecture; Testing; Event-Driven Microservices; Message DB
Cover
Table of Contents
Acknowledgments
Introduction
Telling a Tale of a Different Kind of Keyboard
What This Book Is
What This Book Isn’t
Separating Principles from Implementations
Using This Book
Using Node.js
Strapping In
Part I—Fundamentals
1. You Have a New Project
Kicking Off Video Tutorials
Building the Bones
Mounting Middleware
Injecting Dependencies
Taking the Server for a Spin and Starting the Database
Serving the Home Page
Connecting the Home Page Application
Mounting the Home Application into Express
Building the Record Views Application
Recording State Changes
Charting a New Course
What You’ve Done So Far
2. Writing Messages
Unmasking the Monolith
Trying to Compress Water
Extracting “Microservices”
Defining Services
Getting Components to Do Things
Representing Messages in Code
Naming Messages
Storing State as Events
Storing Messages in Streams
Defining Component Boundaries
Recording Video Views
Writing Your First Message
(Re)configuring the Record-Viewings Application
Hanging a Lantern
What You’ve Done So Far
3. Putting Data in a Message Store
Defining Requirements
Fleshing Out Message Structure
Surveying Message DB
Scaffolding the Message Store Code
Connecting to Message DB
Writing write
Adding Optimistic Concurrency Control to Our Writes
“Can’t Kafka Do All of This?”
What You’ve Done So Far
4. Projecting Data into Useful Shapes
Handling Events
(Re)Introducing the RDBMS
Writing Your First Aggregator
Handling Asynchronous Messages
Getting Idempotent with It
Connecting to the Live Message Flow
Configuring the Aggregator
Having the Home Page Application Use the New View Data
Coming to Terms with Data Duplication
What You’ve Done So Far
5. Subscribing to the Message Store
Sketching the Subscription Process
Managing the Current Read Position
Fetching and Processing Batches of Messages
Orchestrating the Subscription
Reading the Last Message in a Stream
Reading a Stream’s Messages
Adding the Read Functions to the Message Store’s Interface
Starting the Server
What You’ve Done So Far
Part II—Fleshing Out the System
6. Registering Users
Discovering Domain Messages
Starting with the Business Process
Translating the Business Processes into Events and Commands
Fleshing Out the Identity Messages
Examples from Other Domains
Adding Registration to Our System
Turning Registration Requests into Commands
Superficially Validating User Input
Ensuring Uniqueness of Email Addresses
Finishing the Application
Validating Eventually Consistent Data
Coping with Trade-Offs
What You’ve Done So Far
7. Implementing Your First Component
Fetching a Stream’s Current State
Joining the “I Wrote a Microservice” Club
Wiring the Identity Component into the System
Disambiguating “Projections” and “Replaying”
Taking It Further
What You’ve Done So Far
8. Authenticating Users
Aggregating Registered Events
Discovering the Authentication Events and Commands
Letting Users in the Door
Using Third-Party Authentication
What You’ve Done So Far
9. Adding an Email Component
Discovering the Email Component Messages
Addressing Idempotence
Adding the Component
Sending the Email
Running the Component
Adding Email to the Registration Process
Recording Registration Emails
Making the Message Store Aware of Origin Streams
Revisiting Idempotence
Orchestrating Components vs. Choreographing Components
What You’ve Done So Far
10. Performing Background Jobs with Microservices
Accidental Complexity
Use Case #1: Sending Emails
Use Case #2: Transcoding Videos
Describing the Creators Portal
Aggregating Is Also for Other Teams
Building the Video Publishing Component
Accepting Potential Duplication
What You’ve Done So Far
11. Building Async-Aware User Interfaces
Defining Video Metadata Messages
Responding to Users When the Response Isn’t Immediately Available
Adding Validation to a Component
Aggregating Naming Results
Applying Naming Events to the Creators Portal View Data
Justifying Our UI Decision
What You’ve Done So Far
Part III—Tools of the Trade
12. Deploying Components
Creating the Heroku “App”
Configuring the “App”
Installing Message DB
Deploying the System
Distributing the System
Deploying Databases
What You’ve Done So Far
13. Debugging Components
Priming the Database with Example Data
Introducing the Admin Portal
Creating Users
Wiring the Users View into the Admin Portal
Hooking the Admin Portal into the Rest of the System
Inspecting the Results So Far
Thinking Through the Expected Flow
Correlators Gonna…Correlate?
Imagining Our Way to Good System Monitoring
Starting from the Beginning
Viewing Messages by Stream
Augmenting the Message Store for $any and $all
What You’ve Done So Far
14. Testing in a Microservices Architecture
Revisiting the Fundamentals
Writing Tests for Autonomous Components
Writing Tests for Message-Writing Applications
Keeping It Simple
Dropping Testing?
What You’ve Done So Far
15. Continuing the Journey
Handling Concurrency
Snapshotting
Changing the Message Contract
Using Different Programming Languages
Making Use of Monoliths
What You’ve Done So Far
A1. ES6 Syntax
const and let
Arrow Functions
Object Destructuring
Object Literal Property Value Shorthand
Index
– SYMBOLS –
– A –
– B –
– C –
– D –
– E –
– F –
– G –
– H –
– I –
– J –
– K –
– L –
– M –
– N –
– O –
– P –
– Q –
– R –
– S –
– T –
– U –
– V –
– W –
– Y –
– Z –