starling-starling 0.9.9 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +4 -0
- data/README.rdoc +9 -7
- data/etc/starling.ubuntu +1 -1
- data/lib/starling.rb +12 -40
- data/lib/starling/server.rb +1 -1
- data/spec/starling_server_spec.rb +6 -4
- metadata +10 -4
data/CHANGELOG
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
== 0.10.0
|
2
|
+
* Solved compatibility issues with the new (and awesome, thanks mperham) Memcache client
|
3
|
+
* Fixed the old rspec tests.
|
4
|
+
|
1
5
|
== 0.9.9
|
2
6
|
* remove dependency on SyslogLogger so that starling works on windows.
|
3
7
|
* fix config file loading so relative paths are expanded properly <jacob@jacobatzen.dk>
|
data/README.rdoc
CHANGED
@@ -11,7 +11,7 @@ that speaks MemCache can take advantage of Starling's queue facilities.
|
|
11
11
|
|
12
12
|
= Installation
|
13
13
|
|
14
|
-
|
14
|
+
The Starling source is hosted at GitHub and can be found at:
|
15
15
|
|
16
16
|
http://github.com/starling/starling/tree/master
|
17
17
|
|
@@ -44,7 +44,7 @@ that speaks MemCache can take advantage of Starling's queue facilities.
|
|
44
44
|
>> require 'starling'
|
45
45
|
=> true
|
46
46
|
>> starling = Starling.new('127.0.0.1:22122')
|
47
|
-
=> MemCache: 1 servers,
|
47
|
+
=> MemCache: 1 servers, ns: nil, ro: false
|
48
48
|
>> starling.set('my_queue', 12345)
|
49
49
|
=> nil
|
50
50
|
>> starling.get('my_queue')
|
@@ -67,13 +67,13 @@ that speaks MemCache can take advantage of Starling's queue facilities.
|
|
67
67
|
|
68
68
|
'rdoc'
|
69
69
|
|
70
|
-
= Using
|
70
|
+
= Using memcache-client
|
71
71
|
|
72
|
-
memcache-client
|
72
|
+
memcache-client is now maintained by Mike Perham (http://www.mikeperham.com/)
|
73
73
|
|
74
|
-
|
74
|
+
He is the current maintainer of the gem which is hosted at GitHub and can be found at:
|
75
75
|
|
76
|
-
|
76
|
+
http://github.com/mperham/memcache-client/tree/master
|
77
77
|
|
78
78
|
It can be installed using:
|
79
79
|
|
@@ -81,10 +81,11 @@ that speaks MemCache can take advantage of Starling's queue facilities.
|
|
81
81
|
gem sources -a http://gems.github.com/
|
82
82
|
|
83
83
|
# As often as you like
|
84
|
-
sudo gem install
|
84
|
+
sudo gem install memcache-client
|
85
85
|
|
86
86
|
= Known Issues
|
87
87
|
|
88
|
+
* Only tested with Memcache client 1.7.x and with SystemTimer (http://systemtimer.rubyforge.org/)
|
88
89
|
* Starling is "slow" as far as messaging systems are concerned. In practice,
|
89
90
|
it's fast enough.
|
90
91
|
|
@@ -99,6 +100,7 @@ that speaks MemCache can take advantage of Starling's queue facilities.
|
|
99
100
|
* AnotherBritt <?>
|
100
101
|
* Glenn Rempe <?>
|
101
102
|
* Abdul-Rahman Advany <abdulrahman@advany.com>
|
103
|
+
* Harm Aarts <harmaarts@gmail.com>
|
102
104
|
|
103
105
|
= Copyright
|
104
106
|
|
data/etc/starling.ubuntu
CHANGED
data/lib/starling.rb
CHANGED
@@ -43,17 +43,10 @@ class Starling < MemCache
|
|
43
43
|
# yields to the block provided. This helps work around the
|
44
44
|
# normally random nature of the #get_server_for_key method.
|
45
45
|
#
|
46
|
-
|
47
|
-
# since unrelated calls to #get_server_for_key might be
|
48
|
-
# adversely affected by the non_random result.
|
49
|
-
def with_servers(my_servers = @servers.dup)
|
46
|
+
def with_servers(my_servers = self.servers.dup)
|
50
47
|
return unless block_given?
|
51
|
-
|
52
|
-
|
53
|
-
@force_server = server
|
54
|
-
yield
|
55
|
-
end
|
56
|
-
@force_server = nil
|
48
|
+
my_servers.each do |server|
|
49
|
+
yield
|
57
50
|
end
|
58
51
|
end
|
59
52
|
|
@@ -131,38 +124,17 @@ class Starling < MemCache
|
|
131
124
|
def get_server_for_key(key)
|
132
125
|
raise ArgumentError, "illegal character in key #{key.inspect}" if key =~ /\s/
|
133
126
|
raise ArgumentError, "key too long #{key.inspect}" if key.length > 250
|
134
|
-
raise MemCacheError, "No servers available" if
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
n = rand(
|
140
|
-
server =
|
127
|
+
raise MemCacheError, "No servers available" if servers.empty?
|
128
|
+
|
129
|
+
# Ignores server weights, oh well
|
130
|
+
srvs = servers.dup
|
131
|
+
srvs.size.times do |try|
|
132
|
+
n = rand(srvs.size)
|
133
|
+
server = srvs[n]
|
141
134
|
return server if server.alive?
|
142
|
-
|
135
|
+
srvs.delete_at(n)
|
143
136
|
end
|
144
|
-
|
137
|
+
|
145
138
|
raise MemCacheError, "No servers available (all dead)"
|
146
139
|
end
|
147
|
-
end
|
148
|
-
|
149
|
-
|
150
|
-
class MemCache
|
151
|
-
|
152
|
-
protected
|
153
|
-
|
154
|
-
##
|
155
|
-
# Ensure that everything within the given block is executed
|
156
|
-
# within the locked mutex if this client is multithreaded.
|
157
|
-
# If the client isn't multithreaded, the block is simply executed.
|
158
|
-
def with_lock
|
159
|
-
return unless block_given?
|
160
|
-
begin
|
161
|
-
@mutex.lock if @multithread
|
162
|
-
yield
|
163
|
-
ensure
|
164
|
-
@mutex.unlock if @multithread
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
140
|
end
|
data/lib/starling/server.rb
CHANGED
@@ -124,8 +124,8 @@ describe "StarlingServer" do
|
|
124
124
|
|
125
125
|
it "should output statistics per server" do
|
126
126
|
stats = @client.stats
|
127
|
-
|
128
|
-
|
127
|
+
stats.kind_of? Hash
|
128
|
+
stats.has_key?('127.0.0.1:22133').should be_true
|
129
129
|
|
130
130
|
server_stats = stats['127.0.0.1:22133']
|
131
131
|
|
@@ -140,8 +140,10 @@ describe "StarlingServer" do
|
|
140
140
|
end
|
141
141
|
|
142
142
|
it "should return valid response with unkown command" do
|
143
|
-
|
144
|
-
|
143
|
+
#why is this an unknown command?
|
144
|
+
lambda {
|
145
|
+
response = @client.add('blah', 1)
|
146
|
+
}.should raise_error(MemCache::MemCacheError)
|
145
147
|
end
|
146
148
|
|
147
149
|
it "should disconnect and reconnect again" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: starling-starling
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Blaine Cook
|
@@ -10,24 +10,28 @@ authors:
|
|
10
10
|
- Glenn Rempe
|
11
11
|
- Abdul-Rahman Advany
|
12
12
|
- Seth Fitzsimmons
|
13
|
+
- Harm Aarts
|
14
|
+
- Chris Gaffney
|
13
15
|
autorequire:
|
14
16
|
bindir: bin
|
15
17
|
cert_chain: []
|
16
18
|
|
17
|
-
date:
|
19
|
+
date: 2009-04-01 00:00:00 -07:00
|
18
20
|
default_executable:
|
19
21
|
dependencies:
|
20
22
|
- !ruby/object:Gem::Dependency
|
21
|
-
name:
|
23
|
+
name: memcache-client
|
24
|
+
type: :runtime
|
22
25
|
version_requirement:
|
23
26
|
version_requirements: !ruby/object:Gem::Requirement
|
24
27
|
requirements:
|
25
28
|
- - ">="
|
26
29
|
- !ruby/object:Gem::Version
|
27
|
-
version:
|
30
|
+
version: 1.7.0
|
28
31
|
version:
|
29
32
|
- !ruby/object:Gem::Dependency
|
30
33
|
name: eventmachine
|
34
|
+
type: :runtime
|
31
35
|
version_requirement:
|
32
36
|
version_requirements: !ruby/object:Gem::Requirement
|
33
37
|
requirements:
|
@@ -41,6 +45,8 @@ email:
|
|
41
45
|
- chris@ozmm.org
|
42
46
|
- abdulrahman@advany.com
|
43
47
|
- starlingmq@groups.google.com
|
48
|
+
- harmaarts@gmail.com
|
49
|
+
- gaffneyc@gmail.com
|
44
50
|
executables:
|
45
51
|
- starling
|
46
52
|
- starling_top
|