Leanpub Header

Skip to main content

Advent of Go Microservices

Writing good services in Go can be a challenge - you have to write out your database structures, unit and integration testing with CI to see what breaks, keep them updated with migrations, define your API endpoints and routing, update your documentation - all of these things keep you from building your service. Let's be smart about it.

Minimum price

$29.00

$49.00

You pay

$49.00

Author earns

$39.20
$

...Or Buy With Credits!

You can get credits monthly with a Reader Membership
PDF
EPUB
WEB
148
Pages
29,072Words
About

About

About the Book

Are you stuck writing boilerplate code for your microservice?

The book takes you on a 24 chapter adventure where you'll learn how to get rid of the chore work that is keeping you from actually writing your microservices. We'll resort to automation for taking care of your data structures, SQL migrations, API endpoints and routing, updating your documentation, along with CI and monitoring - all the things you need, but at the same time don't need to do by hand.

Author

About the Author

Tit Petric

I'm a seasoned veteran of software engineering. Interested in performance optimization and problem solving. High traffic, high availability, virtualization, docker - these are the categories in which I live.

Contents

Table of Contents

Introduction

  1. About me
  2. Who is this book for?
  3. How should I study it?

Requirements

  1. Linux and Docker

Go: Introduction to Protobuf: Messages

  1. Protobufs and Go
  2. Generating Protobuf Go code
  3. Wrapping up

Go: Introduction to Protobuf: Services

  1. Protobuf service definitions
  2. Our microservice
  3. Twitch RPC scaffolding

Go: Introduction to Protobuf: gRPC

  1. Generating the gRPC scaffolding
  2. Comparing the server side
  3. Comparing the client side

Make: Dynamic Makefile targets

  1. Building multiple targets with Go
  2. Dynamic Makefile target for building RPC/Protobuf files
  3. Building our services from cmd/

Bash: Poor mans code generation

  1. Generating our service cmd/ folders
  2. Generating the client for our service
  3. Server implementation

Bash: Embedding files into Go

  1. Planning database migrations
  2. Poor mans file embedding

Go: Scaffolding database migrations

  1. The migration API

Drone CI: Testing database migrations

  1. Configuring Drone CI for database integration tests

Go: Database first struct generation

  1. Database schema data structures and helpers
  2. Querying information schema
  3. Type conversions
  4. Moving forward

Go: Generating database schema documentation

  1. Updating the Go generators
  2. Implementing a markdown output renderer
  3. A caveat emptor about database migrations

Go: Dependency injection with Wire

  1. The Go way
  2. Runtime vs. compile time
  3. Wire and dependency providers
  4. Wire and dependency Injector

Docker: Building images with security in mind

  1. Configuring Makefile targets
  2. The basic Dockerfile image
  3. Security implications of our docker image
  4. Possible improvements

Go: implementing a microservice

  1. The database schema
  2. Improving the microservice environment
  3. Implementing Push

Docker/Bash: Issuing requests against our microservice

  1. The docker-compose file
  2. Our first request

Go: Improving our database handling

  1. Data source name - DSN
  2. Multiple database connections
  3. Updating database connections
  4. Database connection retry
  5. Migration improvements
  6. Re-testing the bundled migrations

Go: Instrumenting the HTTP service with Elastic APM

  1. Wrapping our existing handler
  2. Logging errors too
  3. Setting up ELK
  4. Setting up APM
  5. Configuring our sender
  6. Reviewing ELK data

Go: Instrumenting the Database client with Elastic APM

  1. Extending DB connection
  2. Verifying it’s working

Go: Stress testing our service

  1. Setting up our stress test
  2. Resolving detected errors
  3. Removing context cancellation
  4. Wrapping up

Go: Background jobs

  1. Adding background jobs to our service
  2. Do we really need Init?
  3. The background job
  4. Housekeeping
  5. Verifying everything works

Go: Optimizing requests with a queue

  1. The Queue
  2. The Producer
  3. The Consumer
  4. Benchmarking
  5. Notes and pitfalls

Get the free sample chapters

Click the buttons to get the free sample in PDF or EPUB, or read the sample online here

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $14 million writing, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub