Skip to content

Commit

Permalink
Create Leadership earlier to keep lease alive
Browse files Browse the repository at this point in the history
The lease must be kept alive all the time, else an invalid lease may be
used when the follower is elected leader.
  • Loading branch information
spuun committed Jan 15, 2025
1 parent 0f90c7f commit 188d4f7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/lavinmq/etcd.cr
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,9 @@ module LavinMQ
# Returns a `Leadership` instance
def elect(name, value, ttl = 10) : Leadership
lease_id, _ttl = lease_grant(ttl)
leadership = Leadership.new(self, lease_id)
election_campaign(name, value, lease_id)
Leadership.new(self, lease_id)
leadership
end

def elect_listen(name, &)
Expand Down

0 comments on commit 188d4f7

Please sign in to comment.