At Joyent, we built a similar system for automated postgresql failover called Manatee. I'm sure today we would have used a Raft-based system, but that was not available when we did this work, so we used ZooKeeper. We haven't spent much time polishing Manatee for general consumption, but there's a write-up on how it maintains consistency[1]. The actual component is available here[2], and it's also been ported to Go as part of Flynn[3].
Edit: Manatee uses synchronous replication, not async, so it does not lose data on failover.
At Joyent, we built a similar system for automated postgresql failover called Manatee. I'm sure today we would have used a Raft-based system, but that was not available when we did this work, so we used ZooKeeper. We haven't spent much time polishing Manatee for general consumption, but there's a write-up on how it maintains consistency[1]. The actual component is available here[2], and it's also been ported to Go as part of Flynn[3].
Edit: Manatee uses synchronous replication, not async, so it does not lose data on failover.
[1] https://github.com/joyent/manatee-state-machine
[2] https://github.com/joyent/manatee
[3] https://github.com/flynn/flynn