mperham-politics 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/History.rdoc CHANGED
@@ -1,5 +1,10 @@
1
1
  = Changelog
2
2
 
3
+ == 0.2.2 (2009-01-07)
4
+
5
+ * Fix invalid leader? logic in TokenWorker which could allow
6
+ two workers to become leader at the same time. (Brian Dainton)
7
+
3
8
  == 0.2.1 (2008-11-04)
4
9
 
5
10
  * Cleanup and prepare for public release for RubyConf 2008.
data/README.rdoc CHANGED
@@ -23,6 +23,10 @@ toes? There are several answers:
23
23
  is fault tolerant but not as scalable, as only one process is performing the task at a given
24
24
  point in time. See the +TokenWorker+ mixin.
25
25
 
26
+ == Installation
27
+
28
+ sudo gem install mperham-politics -s http://gems.github.com
29
+
26
30
  == Dependencies
27
31
 
28
32
  StaticQueueWorker mixin
@@ -39,7 +43,7 @@ TokenWorker mixin
39
43
  Name:: Mike Perham
40
44
  Email:: mailto:mperham@gmail.com
41
45
  Twitter:: http://twitter.com/mperham
42
- Homepage:: http://mikeperham.com/politics/
46
+ Homepage:: http://mikeperham.com/
43
47
 
44
48
  This software is free for you to use as you'd like. If you find it useful, please consider giving
45
49
  me a recommendation at {Working with Rails}[http://workingwithrails.com/person/10797-mike-perham].
@@ -142,17 +142,15 @@ module Politics
142
142
 
143
143
  # Nominate ourself as leader by contacting the memcached server
144
144
  # and attempting to add the token with our name attached.
145
+ # The result will tell us if memcached stored our value and therefore
146
+ # if we are now leader.
145
147
  def nominate
146
- memcache_client.add(token, worker_name, iteration_length)
148
+ result = memcache_client.add(token, worker_name, iteration_length)
149
+ @leader = (result == 'STORED')
147
150
  end
148
151
 
149
- # Check to see if we are leader by looking at the process name
150
- # associated with the token.
151
152
  def leader?
152
- @leader ||= begin
153
- master_worker = memcache_client.get(token)
154
- worker_name == master_worker
155
- end
153
+ @leader
156
154
  end
157
155
 
158
156
  # Easy to mock or monkey-patch if another MemCache client is preferred.
@@ -1,5 +1,5 @@
1
1
  module Politics
2
2
  module Version
3
- STRING = "0.2.1"
3
+ STRING = "0.2.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mperham-politics
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Perham
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-10-27 00:00:00 -07:00
12
+ date: 2008-12-22 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency