feat: 分布式锁-故障转移机制

This commit is contained in:
tbphp
2025-07-08 22:02:39 +08:00
parent a159debd77
commit 2d669b7ece
2 changed files with 48 additions and 39 deletions

View File

@@ -77,9 +77,8 @@ func NewApp(params AppParams) *App {
// Start runs the application, it is a non-blocking call.
func (a *App) Start() error {
// Perform leader election first. This is a blocking call.
if err := a.leaderService.ElectLeader(); err != nil {
return fmt.Errorf("leader election failed: %w", err)
if err := a.leaderService.Start(); err != nil {
return fmt.Errorf("leader service failed to start: %w", err)
}
if a.leaderService.IsLeader() {