daikon 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/daikon.gemspec +3 -2
- data/lib/daikon.rb +2 -1
- data/lib/daikon/client.rb +6 -2
- data/lib/daikon/redis_hacks.rb +43 -0
- metadata +5 -4
data/daikon.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{daikon}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.4.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Nick Quaranto"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-12-06}
|
13
13
|
s.default_executable = %q{daikon}
|
14
14
|
s.description = %q{daikon, a radishapp.com client}
|
15
15
|
s.email = %q{nick@quaran.to}
|
@@ -36,6 +36,7 @@ Gem::Specification.new do |s|
|
|
36
36
|
"lib/daikon/configuration.rb",
|
37
37
|
"lib/daikon/daemon.rb",
|
38
38
|
"lib/daikon/namespace_tools.rb",
|
39
|
+
"lib/daikon/redis_hacks.rb",
|
39
40
|
"spec/client_spec.rb",
|
40
41
|
"spec/configuration_spec.rb",
|
41
42
|
"spec/daemon_spec.rb",
|
data/lib/daikon.rb
CHANGED
data/lib/daikon/client.rb
CHANGED
@@ -17,17 +17,21 @@ module Daikon
|
|
17
17
|
def setup(config, logger = nil)
|
18
18
|
self.config = config
|
19
19
|
self.logger = logger
|
20
|
-
self.redis =
|
20
|
+
self.redis = connect
|
21
21
|
self.http = Net::HTTP::Persistent.new
|
22
22
|
http.headers['Authorization'] = config.api_key
|
23
23
|
|
24
24
|
log "Started Daikon v#{VERSION}"
|
25
25
|
end
|
26
26
|
|
27
|
+
def connect
|
28
|
+
Redis.new(:host => config.redis_host, :port => config.redis_port)
|
29
|
+
end
|
30
|
+
|
27
31
|
def start_monitor
|
28
32
|
self.monitor = StringIO.new
|
29
33
|
Thread.new do
|
30
|
-
|
34
|
+
connect.monitor do |line|
|
31
35
|
monitor.puts line
|
32
36
|
end
|
33
37
|
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# All of this craziness is necessary since redis-rb doesn't support the
|
2
|
+
# old way of connecting to MONITOR since it doesn't return the format bytes
|
3
|
+
|
4
|
+
class Redis
|
5
|
+
def monitor(&block)
|
6
|
+
@_redis_version ||= info["redis_version"]
|
7
|
+
|
8
|
+
if @_redis_version < "2"
|
9
|
+
@client.call_loop_with_old_protocol(:monitor, &block)
|
10
|
+
else
|
11
|
+
@client.call_loop(:monitor, &block)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class Client
|
16
|
+
def call_loop_with_old_protocol(*args)
|
17
|
+
without_socket_timeout do
|
18
|
+
process(args) do
|
19
|
+
loop { yield(read_with_old_protocol) }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def read_with_old_protocol
|
25
|
+
begin
|
26
|
+
connection.read_with_old_protocol
|
27
|
+
rescue Errno::EAGAIN
|
28
|
+
disconnect
|
29
|
+
raise Errno::EAGAIN, "Timeout reading from the socket"
|
30
|
+
rescue Errno::ECONNRESET
|
31
|
+
raise Errno::ECONNRESET, "Connection lost"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
class Connection
|
37
|
+
def read_with_old_protocol
|
38
|
+
reply_type = @sock.gets
|
39
|
+
raise Errno::ECONNRESET unless reply_type
|
40
|
+
reply_type
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: daikon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 4
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.4.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Nick Quaranto
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-12-06 00:00:00 -05:00
|
19
19
|
default_executable: daikon
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -195,6 +195,7 @@ files:
|
|
195
195
|
- lib/daikon/configuration.rb
|
196
196
|
- lib/daikon/daemon.rb
|
197
197
|
- lib/daikon/namespace_tools.rb
|
198
|
+
- lib/daikon/redis_hacks.rb
|
198
199
|
- spec/client_spec.rb
|
199
200
|
- spec/configuration_spec.rb
|
200
201
|
- spec/daemon_spec.rb
|