Skip to content

(Ruby) To avoid to run the same batch at the same time. You can use this for script/runner

Notifications You must be signed in to change notification settings

ecpplus/batch_lock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

To avoid running same batch at the same time. 
This is useful for Rails script/runner, for example.

== Usage

BatchLock.run(batch_name, &block)
Lock some batch.

BatchLock.running?(batch_name, &block)
Check some batch running?


== Example

begin
  BatchLock.run(:go_to_park) do
    # All users go to park!
    User.find(all).each(&:go_to_park)
  end
rescue BatchLockException
  logger.error "already running..."
end


If another batch named :go_to_park is running, you can't run batch.

About

(Ruby) To avoid to run the same batch at the same time. You can use this for script/runner

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages