readwrite lock implementation?

123 views
Skip to first unread message

Steve Johnson

unread,
Dec 9, 2015, 3:10:47 PM12/9/15
to Consul
Can anyone tell me how to implement a readwrite lock via Consul?  That is, I want a lock that allows multiple readers but requires exclusive access for writing.


Armon Dadgar

unread,
Dec 9, 2015, 7:14:10 PM12/9/15
to consu...@googlegroups.com, Steve Johnson
Hey Steve,

Take a look at the guide on implementing a semaphore using Consul here:

A read/write lock is basically a semaphore with a “mode”. In the “write” mode the
limit is one, and in the “read” mode the limit is potentially infinite. You should be able
to follow the same basic steps with the extra nuance of specifying the lock mode in
the shared key.

Here is a Go implementation of the semaphore pattern as well:

Best Regards,
Armon Dadgar
--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/hashicorp/consul/issues
IRC: #consul on Freenode
---
You received this message because you are subscribed to the Google Groups "Consul" group.
To unsubscribe from this group and stop receiving emails from it, send an email to consul-tool...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/consul-tool/2c8b0305-85a0-4d43-82a0-0be320629c0e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Armon Dadgar

unread,
Dec 9, 2015, 8:15:03 PM12/9/15
to consu...@googlegroups.com, Steve Johnson
Hey Steve,

Take a look at the guide on implementing a semaphore using Consul here:

A read/write lock is basically a semaphore with a “mode”. In the “write” mode the
limit is one, and in the “read” mode the limit is potentially infinite. You should be able
to follow the same basic steps with the extra nuance of specifying the lock mode in
the shared key.

Here is a Go implementation of the semaphore pattern as well:

Best Regards,
Armon Dadgar

From: Steve Johnson <blat...@gmail.com>
Reply: consu...@googlegroups.com <consu...@googlegroups.com>>
Date: December 9, 2015 at 12:10:49 PM
To: Consul <consu...@googlegroups.com>>
Subject:  [consul] readwrite lock implementation?

Reply all
Reply to author
Forward
0 new messages