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 +5 -0
- data/README.rdoc +5 -1
- data/lib/politics/token_worker.rb +5 -7
- data/lib/politics/version.rb +1 -1
- metadata +2 -2
data/History.rdoc
CHANGED
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/
|
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
|
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.
|
data/lib/politics/version.rb
CHANGED
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.
|
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-
|
12
|
+
date: 2008-12-22 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|