Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hayesgm/go-etcd-lock
A simple lock library on top of etcd in Go
https://github.com/hayesgm/go-etcd-lock
Last synced: about 1 month ago
JSON representation
A simple lock library on top of etcd in Go
- Host: GitHub
- URL: https://github.com/hayesgm/go-etcd-lock
- Owner: hayesgm
- License: mit
- Created: 2013-09-08T08:28:40.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2013-12-03T22:15:02.000Z (almost 11 years ago)
- Last Synced: 2024-06-21T17:05:37.141Z (5 months ago)
- Language: Go
- Size: 122 KB
- Stars: 3
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
go-etcd-lock
============A simple lock library on top of etcd in Go.
Locks are acquired with a timeout which will be automatically refreshed so long as the node with the lock remains alive. If a node holding a lock were to die, the lock would automatically
release after the timeout period, and a new node would be granted the lock.# Example
import "github.com/hayesgm/go-etcd-lock/lock"
goChan, stopChan := lock.Acquire(cli, "mylock", 20) // Try to get a lock with 20 second timeout
go func() {
<- goChan // Wait to Acquire lock
for run := true; run; {
select {
case <-stopChan:
run = false // We're going to exit
default:
log.Println("I am king")
}
}
}