resque-lock-timeout 0.3.1 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
data/HISTORY.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 0.3.3 (2012-03-09)
2
+ ## 0.3.2 (2012-03-09)
3
+
4
+ * Release changes nothing of importance, tested against v1.20.0 of resque.
5
+
1
6
  ## 0.3.1 (2011-07-16)
2
7
 
3
8
  * Pass job arguments to `lock_timeout`. (Bob Potter)
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  Resque Lock Timeout
2
2
  ===================
3
3
 
4
- A [Resque][rq] plugin. Requires Resque >= 01.8.0.
4
+ A [Resque][rq] plugin. Requires Resque >= v1.8.0.
5
5
 
6
6
  resque-lock-timeout adds locking, with optional timeout/deadlock handling to
7
7
  resque jobs.
@@ -61,16 +61,12 @@ Customise & Extend
61
61
 
62
62
  ### Job Identifier/Lock Key
63
63
 
64
- The key is built using the `identifier`. If you have a lot of arguments or
65
- really long ones, you should consider overriding `identifier` to define a
66
- more precise or loose custom identifier.
64
+ By default the key uses this format: `lock:<job class name>:<identifier>`.
67
65
 
68
66
  The default identifier is just your job arguments joined with a dash `-`.
69
67
 
70
- By default the key uses this format:
71
- `resque-lock-timeout:<job class name>:<identifier>`.
72
-
73
- Or you can define the entire key by overriding `redis_lock_key`.
68
+ If you have a lot of arguments or really long ones, you should consider
69
+ overriding `identifier` to define a more precise or loose custom identifier:
74
70
 
75
71
  class UpdateNetworkGraph
76
72
  extend Resque::Plugins::LockTimeout
@@ -90,7 +86,24 @@ The above modification will ensure only one job of class
90
86
  UpdateNetworkGraph is running at a time, regardless of the
91
87
  repo_id.
92
88
 
93
- It's lock key would be: `resque-lock-timeout:UpdateNetworkGraph`.
89
+ Its lock key would be: `lock:UpdateNetworkGraph` (the `:<identifier>` part is left out if the identifier is `nil`).
90
+
91
+ You can define the entire key by overriding `redis_lock_key`:
92
+
93
+ class UpdateNetworkGraph
94
+ extend Resque::Plugins::LockTimeout
95
+ @queue = :network_graph
96
+
97
+ def self.redis_lock_key(repo_id)
98
+ "lock:updates"
99
+ end
100
+
101
+ def self.perform(repo_id)
102
+ heavy_lifting
103
+ end
104
+ end
105
+
106
+ That would use the key `lock:updates`.
94
107
 
95
108
  ### Redis Connection Used for Locking
96
109
 
data/Rakefile CHANGED
@@ -4,7 +4,7 @@ require 'yard/rake/yardoc_task'
4
4
 
5
5
  task :default => :test
6
6
 
7
- desc 'Run tests.'
7
+ desc 'Run unit tests.'
8
8
  Rake::TestTask.new(:test) do |task|
9
9
  task.test_files = FileList['test/*_test.rb']
10
10
  task.verbose = true
@@ -13,7 +13,7 @@ end
13
13
  desc 'Build Yardoc documentation.'
14
14
  YARD::Rake::YardocTask.new :yardoc do |t|
15
15
  t.files = ['lib/**/*.rb']
16
- t.options = ['--output-dir', "doc/",
16
+ t.options = ['--output-dir', 'doc/',
17
17
  '--files', 'LICENSE,HISTORY.md',
18
18
  '--readme', 'README.md',
19
19
  '--title', 'resque-lock-timeout documentation']
@@ -1 +1,2 @@
1
+ require 'resque'
1
2
  require 'resque/plugins/lock_timeout'
@@ -3,7 +3,7 @@ module Resque
3
3
  # If you want only one instance of your job running at a time,
4
4
  # extend it with this module:
5
5
  #
6
- # require 'resque-lock'
6
+ # require 'resque-lock-timeout'
7
7
  #
8
8
  # class UpdateNetworkGraph
9
9
  # extend Resque::Plugins::LockTimeout
@@ -62,7 +62,7 @@ module Resque
62
62
  # @param [Array] args job arguments
63
63
  # @return [String] redis key
64
64
  def redis_lock_key(*args)
65
- ['lock', name, identifier(*args)].compact.join(":")
65
+ ['lock', name, identifier(*args)].compact.join(':')
66
66
  end
67
67
 
68
68
  # Number of seconds the lock may be held for.
@@ -1,16 +1,15 @@
1
1
  require File.dirname(__FILE__) + '/test_helper'
2
2
 
3
- class LockTest < Test::Unit::TestCase
3
+ class LockTest < MiniTest::Unit::TestCase
4
4
  def setup
5
5
  $success = $lock_failed = $lock_expired = 0
6
6
  Resque.redis.flushall
7
7
  @worker = Resque::Worker.new(:test)
8
8
  end
9
9
 
10
- def test_lint
11
- assert_nothing_raised do
12
- Resque::Plugin.lint(Resque::Plugins::LockTimeout)
13
- end
10
+ def test_resque_plugin_lint
11
+ # will raise exception if were not a good plugin.
12
+ assert Resque::Plugin.lint(Resque::Plugins::LockTimeout)
14
13
  end
15
14
 
16
15
  def test_version
@@ -120,7 +119,7 @@ class LockTest < Test::Unit::TestCase
120
119
  # this is nil in Resque.redis since we make no attempt to add a resque:
121
120
  # prefix to the key
122
121
  assert_nil Resque.redis.get('specific_redis')
123
- assert_not_nil lock_redis.get('specific_redis')
122
+ assert lock_redis.get('specific_redis')
124
123
 
125
124
  thread.join
126
125
  assert_nil lock_redis.get('specific_redis')
@@ -2,40 +2,39 @@ dir = File.dirname(File.expand_path(__FILE__))
2
2
  $LOAD_PATH.unshift dir + '/../lib'
3
3
  $TESTING = true
4
4
 
5
- require 'test/unit'
6
- require 'resque'
7
- require 'turn'
5
+ require 'rubygems'
6
+ require 'minitest/unit'
7
+ require 'minitest/pride'
8
+ require 'simplecov'
9
+
10
+ SimpleCov.start do
11
+ add_filter '/test/'
12
+ end unless RUBY_PLATFORM == 'java'
8
13
 
9
14
  require 'resque-lock-timeout'
10
15
  require dir + '/test_jobs'
11
16
 
12
- ##
13
17
  # make sure we can run redis
14
- if !system("which redis-server")
18
+ if !system('which redis-server')
15
19
  puts '', "** can't find `redis-server` in your path"
16
- puts "** try running `sudo rake install`"
20
+ puts '** try running `sudo rake install`'
17
21
  abort ''
18
22
  end
19
23
 
20
- ##
21
24
  # start our own redis when the tests start,
22
25
  # kill it when they end
23
26
  at_exit do
24
27
  next if $!
25
28
 
26
- if defined?(MiniTest)
27
- exit_code = MiniTest::Unit.new.run(ARGV)
28
- else
29
- exit_code = Test::Unit::AutoRunner.run
30
- end
29
+ exit_code = MiniTest::Unit.new.run(ARGV)
31
30
 
32
- pid = `ps -e -o pid,command | grep [r]edis-test`.split(" ")[0]
33
- puts "Killing test redis server..."
31
+ pid = `ps -e -o pid,command | grep [r]edis-test`.split(' ')[0]
32
+ puts 'Killing test redis server...'
34
33
  `rm -f #{dir}/dump.rdb`
35
- Process.kill("KILL", pid.to_i)
36
- exit exit_code
34
+ `kill -9 #{pid}`
35
+ exit(exit_code)
37
36
  end
38
37
 
39
- puts "Starting redis for testing at localhost:9736..."
38
+ puts 'Starting redis for testing at localhost:9736...'
40
39
  `redis-server #{dir}/redis-test.conf`
41
40
  Resque.redis = '127.0.0.1:9736'
metadata CHANGED
@@ -1,73 +1,105 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: resque-lock-timeout
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.3
4
5
  prerelease:
5
- version: 0.3.1
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Luke Antins
9
9
  - Ryan Carver
10
10
  - Chris Wanstrath
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
-
15
- date: 2011-07-16 00:00:00 +01:00
16
- default_executable:
17
- dependencies:
18
- - !ruby/object:Gem::Dependency
14
+ date: 2012-03-09 00:00:00.000000000Z
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
19
17
  name: resque
20
- prerelease: false
21
- requirement: &id001 !ruby/object:Gem::Requirement
18
+ requirement: &2155990660 !ruby/object:Gem::Requirement
22
19
  none: false
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
20
+ requirements:
21
+ - - ! '>='
22
+ - !ruby/object:Gem::Version
26
23
  version: 1.8.0
27
24
  type: :runtime
28
- version_requirements: *id001
29
- - !ruby/object:Gem::Dependency
30
- name: turn
31
25
  prerelease: false
32
- requirement: &id002 !ruby/object:Gem::Requirement
26
+ version_requirements: *2155990660
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: &2155972620 !ruby/object:Gem::Requirement
33
30
  none: false
34
- requirements:
35
- - - ">="
36
- - !ruby/object:Gem::Version
37
- version: "0"
31
+ requirements:
32
+ - - ! '>='
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: *2155972620
38
+ - !ruby/object:Gem::Dependency
39
+ name: minitest
40
+ requirement: &2155947800 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
38
46
  type: :development
39
- version_requirements: *id002
40
- - !ruby/object:Gem::Dependency
41
- name: yard
42
47
  prerelease: false
43
- requirement: &id003 !ruby/object:Gem::Requirement
48
+ version_requirements: *2155947800
49
+ - !ruby/object:Gem::Dependency
50
+ name: json
51
+ requirement: &2155922920 !ruby/object:Gem::Requirement
44
52
  none: false
45
- requirements:
46
- - - ">="
47
- - !ruby/object:Gem::Version
48
- version: "0"
53
+ requirements:
54
+ - - ! '>='
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
49
57
  type: :development
50
- version_requirements: *id003
51
- - !ruby/object:Gem::Dependency
58
+ prerelease: false
59
+ version_requirements: *2155922920
60
+ - !ruby/object:Gem::Dependency
61
+ name: yard
62
+ requirement: &2155919780 !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ! '>='
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: *2155919780
71
+ - !ruby/object:Gem::Dependency
52
72
  name: rdiscount
73
+ requirement: &2155916580 !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ type: :development
53
80
  prerelease: false
54
- requirement: &id004 !ruby/object:Gem::Requirement
81
+ version_requirements: *2155916580
82
+ - !ruby/object:Gem::Dependency
83
+ name: simplecov
84
+ requirement: &2155910660 !ruby/object:Gem::Requirement
55
85
  none: false
56
- requirements:
57
- - - ">="
58
- - !ruby/object:Gem::Version
59
- version: "0"
86
+ requirements:
87
+ - - ! '>='
88
+ - !ruby/object:Gem::Version
89
+ version: 0.3.0
60
90
  type: :development
61
- version_requirements: *id004
62
- description: " A Resque plugin. Adds locking, with optional timeout/deadlock handling to\n resque jobs.\n\n Using a `lock_timeout` allows you to re-aquire the lock should your worker\n fail, crash, or is otherwise unable to relase the lock.\n \n i.e. Your server unexpectedly looses power. Very handy for jobs that are\n recurring or may be retried.\n"
91
+ prerelease: false
92
+ version_requirements: *2155910660
93
+ description: ! " A Resque plugin. Adds locking, with optional timeout/deadlock handling
94
+ to\n resque jobs.\n\n Using a `lock_timeout` allows you to re-aquire the lock
95
+ should your worker\n fail, crash, or is otherwise unable to relase the lock.\n
96
+ \ \n i.e. Your server unexpectedly looses power. Very handy for jobs that are\n
97
+ \ recurring or may be retried.\n"
63
98
  email: luke@lividpenguin.com
64
99
  executables: []
65
-
66
100
  extensions: []
67
-
68
101
  extra_rdoc_files: []
69
-
70
- files:
102
+ files:
71
103
  - README.md
72
104
  - Rakefile
73
105
  - LICENSE
@@ -78,33 +110,30 @@ files:
78
110
  - test/redis-test.conf
79
111
  - test/test_helper.rb
80
112
  - test/test_jobs.rb
81
- has_rdoc: false
82
113
  homepage: http://github.com/lantins/resque-lock-timeout
83
114
  licenses: []
84
-
85
115
  post_install_message:
86
116
  rdoc_options: []
87
-
88
- require_paths:
117
+ require_paths:
89
118
  - lib
90
- required_ruby_version: !ruby/object:Gem::Requirement
119
+ required_ruby_version: !ruby/object:Gem::Requirement
91
120
  none: false
92
- requirements:
93
- - - ">="
94
- - !ruby/object:Gem::Version
95
- version: "0"
96
- required_rubygems_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ! '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
126
  none: false
98
- requirements:
99
- - - ">="
100
- - !ruby/object:Gem::Version
101
- version: "0"
127
+ requirements:
128
+ - - ! '>='
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
102
131
  requirements: []
103
-
104
132
  rubyforge_project:
105
- rubygems_version: 1.6.2
133
+ rubygems_version: 1.8.10
106
134
  signing_key:
107
135
  specification_version: 3
108
- summary: A Resque plugin adding locking, with optional timeout/deadlock handling to resque jobs.
136
+ summary: A Resque plugin adding locking, with optional timeout/deadlock handling to
137
+ resque jobs.
109
138
  test_files: []
110
-
139
+ has_rdoc: false