Advent of Go Microservices
Minimum price
Suggested price

Advent of Go Microservices

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.

  • Share this book

  • Categories

    • Go
    • API Design
    • APIs
    • DevOps
    • Docker
    • Automated Software Testing
    • System Integration
  • Feedback

    Email the Author(s)

About the Author

Tit Petric
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.

Table of Contents

  • Introduction
    • About me
    • Who is this book for?
    • How should I study it?
  • Requirements
    • Linux and Docker
  • Go: Introduction to Protobuf: Messages
    • Protobufs and Go
    • Generating Protobuf Go code
    • Wrapping up
  • Go: Introduction to Protobuf: Services
    • Protobuf service definitions
    • Our microservice
    • Twitch RPC scaffolding
  • Go: Introduction to Protobuf: gRPC
    • Generating the gRPC scaffolding
    • Comparing the server side
    • Comparing the client side
  • Make: Dynamic Makefile targets
    • Building multiple targets with Go
    • Dynamic Makefile target for building RPC/Protobuf files
    • Building our services from cmd/
  • Bash: Poor mans code generation
    • Generating our service cmd/ folders
    • Generating the client for our service
    • Server implementation
  • Bash: Embedding files into Go
    • Planning database migrations
    • Poor mans file embedding
  • Go: Scaffolding database migrations
    • The migration API
  • Drone CI: Testing database migrations
    • Configuring Drone CI for database integration tests
  • Go: Database first struct generation
    • Database schema data structures and helpers
    • Querying information schema
    • Type conversions
    • Moving forward
  • Go: Generating database schema documentation
    • Updating the Go generators
    • Implementing a markdown output renderer
    • A caveat emptor about database migrations
  • Go: Dependency injection with Wire
    • The Go way
    • Runtime vs. compile time
    • Wire and dependency providers
    • Wire and dependency Injector
  • Docker: Building images with security in mind
    • Configuring Makefile targets
    • The basic Dockerfile image
    • Security implications of our docker image
    • Possible improvements
  • Go: implementing a microservice
    • The database schema
    • Improving the microservice environment
    • Implementing Push
  • Docker/Bash: Issuing requests against our microservice
    • The docker-compose file
    • Our first request
  • Go: Improving our database handling
    • Data source name - DSN
    • Multiple database connections
    • Updating database connections
    • Database connection retry
    • Migration improvements
    • Re-testing the bundled migrations
  • Go: Instrumenting the HTTP service with Elastic APM
    • Wrapping our existing handler
    • Logging errors too
    • Setting up ELK
    • Setting up APM
    • Configuring our sender
    • Reviewing ELK data
  • Go: Instrumenting the Database client with Elastic APM
    • Extending DB connection
    • Verifying it’s working
  • Go: Stress testing our service
    • Setting up our stress test
    • Resolving detected errors
    • Removing context cancellation
    • Wrapping up
  • Go: Background jobs
    • Adding background jobs to our service
    • Do we really need Init?
    • The background job
    • Housekeeping
    • Verifying everything works
  • Go: Optimizing requests with a queue
    • The Queue
    • The Producer
    • The Consumer
    • Benchmarking
    • Notes and pitfalls

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.

See full terms

80% Royalties. Earn $16 on a $20 book.

We pay 80% royalties. That's not a typo: you earn $16 on a $20 sale. If we sell 5000 non-refunded copies of your book or course for $20, you'll earn $80,000.

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

In fact, authors have earnedover $12 millionwriting, 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