Also implements a looping to switch over the Patroni leader to ensure this always follows the primary and clean up the code around here a bit.
Also implements a looping to switch over the Patroni leader to ensure this always follows the primary and clean up the code around here a bit.