Project

with_lock

0.0
No commit activity in last 3 years
No release in over 3 years
Implements named mutexes for ruby applications by creating a resource server to query for locks.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

> 2.8, ~> 2.8.0

Runtime

> 1.1, ~> 1.1.9
 Project Readme

WithLock

Provides a DRb service to provide locking across a distributed ruby application.

Installation

Add to your Gemfile and run the bundle command to install it.

gem "with_lock"

Tested under Ruby 1.9.3-p545 and 2.1.3

Add script and config files to your project(from console):

WithLock.setup

In the configuration file you can change some settings if you like ... it defaults to using the following... where 'scope' is the application directory name with rails environment appended(if present): url: druby://loclahost:9999 scope: <%= File.basename(File.expand_path('.')) %><%= ":#{Rails.env}" if defined?(Rails) %> directory: tmp

The scope is used to let different applications use the same drb server ... or different parts of an app acquire the same named locks(not that I think this latter is a great idea) ...

Start/Stop the service from ruby

WithLock::Server.start_service
WithLock::Server.stop_service

Usage

A "with_lock()" function is provided globally to wrap with_lock sections of code.

with_lock('lock_name') do
  puts "This is something only I can do right now, provided others are using the locks!"
end 

Development

Questions or problems? Please post them on the issue tracker. You can contribute changes by forking the project and submitting a pull request. You can ensure the tests passing by running bundle and rake.

This gem is created by Christopher Hauboldt and is under the MIT License.