Created
October 25, 2021 06:50
-
-
Save mayankshah1607/b18db3178176c89fe3ee603e93ac0b34 to your computer and use it in GitHub Desktop.
RunOrDie
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// RunOrDie starts a client with the provided config or panics if the config | |
// fails to validate. RunOrDie blocks until leader election loop is | |
// stopped by ctx or it has stopped holding the leader lease | |
func RunOrDie(ctx context.Context, lec LeaderElectionConfig) { | |
le, err := NewLeaderElector(lec) | |
if err != nil { | |
panic(err) | |
} | |
if lec.WatchDog != nil { | |
lec.WatchDog.SetLeaderElection(le) | |
} | |
le.Run(ctx) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment