Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Go Programming Cookbook

You're reading from   Go Programming Cookbook Over 85 recipes to build modular, readable, and testable Golang applications across various domains

Arrow left icon
Product type Paperback
Published in Jul 2019
Publisher Packt
ISBN-13 9781789800982
Length 434 pages
Edition 2nd Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Aaron Torres Aaron Torres
Author Profile Icon Aaron Torres
Aaron Torres
Arrow right icon
View More author details
Toc

Table of Contents (16) Chapters Close

Preface 1. I/O and Filesystems FREE CHAPTER 2. Command-Line Tools 3. Data Conversion and Composition 4. Error Handling in Go 5. Network Programming 6. All about Databases and Storage 7. Web Clients and APIs 8. Microservices for Applications in Go 9. Testing Go Code 10. Parallelism and Concurrency 11. Distributed Systems 12. Reactive Programming and Data Streams 13. Serverless Programming 14. Performance Improvements, Tips, and Tricks 15. Other Books You May Enjoy

Implementing basic consensus using Raft

Raft is a consensus algorithm. It allows distributed systems to keep a shared and managed state (https://raft.github.io/). Setting up a Raft system is complex in many ways – for one, you need consensus for an election to occur and succeed. This can be difficult to bootstrap when you're working with multiple nodes and can be difficult to get started. It is possible to run a basic cluster on a single node/leader. However, if you want redundancy, at least three nodes are needed to prevent data loss in the case of a single node failure. This concept is known as quorum, where you must maintain (n/2)+1 available nodes to ensure new logs can be committed to the Raft cluster. Basically, if you can maintain quorum, the cluster remains healthy and usable.

This recipe implements a basic in-memory Raft cluster, constructs a state machine that can transition between certain allowed states, and connects the distributed state machine...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at AU $24.99/month. Cancel anytime