I need this functionality for a project, but I don’t know how to do it myself so I’m searching for an open source implementation.

Edit: I’ve learned about the Raft protocol which seems exactly what I needed.