No commit activity in last 3 years
No release in over 3 years
Framework for using a distributed mutex along with an implementation of a mutex stored on a MySQL database.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0

Runtime

< 3.0, >= 2.3
>= 0
 Project Readme

distributed_mutex¶ ↑

by Birkir A. Barkarson <birkirb@stoicviking.net>

Description¶ ↑

A rails plugin proving an abstract distributed mutex along with a MySQL implementation that uses mysql named locks. Others distributed locks using Memcached etc could be implemented using the same framework.

A few words about the naming. It’s a bit confusing, since we’re talking about a mutext that works for a distributed application environment, but is in itself centralized. This is a fairly common environment for Ruby on Rails since many application will run many instances all taking to a centralized database. If so then yes, this could be what you need.

Lastly this is by far the only solution to this kind of problem. Generally you should just be using record locks if you are using a database to begin with. However I did find a use for this where I wanted to prevent a user from executing a certain code path that was only designed to work for a single thread. Why users would try doing the same thing in multiple windows is of course beyond the scope of this text, but a centralized mutex could be used to prevent such undesired assholery.

If you don’t have MySQL or prefer to store your mutex in a different centralized repo (such as memcache, or MongoDB) then adding such an implementation to this one should be trivial.

Installation from source¶ ↑

git clone git://github.com/birkirb/distributed_mutex.git
cd distributed_mutex
rake install

Rails Plugin Installation¶ ↑

script/plugin install git://github.com/birkirb/distributed_mutex.git

Gem Install¶ ↑

gem install distributed_mutex

To add the plugin to your rails project, add the following to your config/environments.rb:

config.gem(:distributed_mutex)

or just stick in your bundle.

Developing¶ ↑

Copy spec/config/database.stub to spec/config/database.yml and edit as needed for your mysql installation.

gem install bundler
bundle install
rake spec
Author

Birkir A. Barkarson <birkirb@stoicviking.net>

Copyright

Copyright © 2009

License

MIT License