Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

api: Adding Lock helpers for leader election #594

Merged
merged 3 commits into from
Jan 12, 2015
Merged

api: Adding Lock helpers for leader election #594

merged 3 commits into from
Jan 12, 2015

Conversation

armon
Copy link
Member

@armon armon commented Jan 10, 2015

This adds a new Lock to the client API. This can be used to implement simple leader election or mutual exclusion via Consul. Modeled on: https://consul.io/docs/guides/leader-election.html

}

// Set that we no longwer own the lock
l.isHeld = false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to set this just before returning. Otherwise if we fail to release the lock, this gets set to false anyways.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only thing that can fail is the KV.Release() but we have to assume the lock is no longer held once that call is started.

@ryanuber
Copy link
Member

@armon I left 1 comment, but otherwise everything LGTM! Super awesome.

return ErrLockNotHeld
}

// Set that we no longwer own the lock
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo. s/longwer/longer/. :-)

armon added a commit that referenced this pull request Jan 12, 2015
api: Adding Lock helpers for leader election
@armon armon merged commit 3cba4df into master Jan 12, 2015
@armon armon deleted the f-api-lock branch January 12, 2015 23:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants