Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
pietern committed Mar 28, 2011
1 parent 43e0db3 commit 8a4af8b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 36 deletions.
35 changes: 17 additions & 18 deletions lib/redis/connection/command_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,27 @@ def build_command(*args)
command
end

protected
protected

if "".respond_to?(:bytesize)
def string_size(string)
string.to_s.bytesize
end
else
def string_size(string)
string.to_s.size
end
if "".respond_to?(:bytesize)
def string_size(string)
string.to_s.bytesize
end

if defined?(Encoding::default_external)
def encode(string)
string.force_encoding(Encoding::default_external)
end
else
def encode(string)
string
end
else
def string_size(string)
string.to_s.size
end
end

if defined?(Encoding::default_external)
def encode(string)
string.force_encoding(Encoding::default_external)
end
else
def encode(string)
string
end
end
end
end
end
33 changes: 15 additions & 18 deletions lib/redis/connection/synchrony.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
require "redis/connection/command_helper"
require "redis/connection/registry"
require "hiredis/connection"

require "em-synchrony"
require "hiredis/reader"

Expand Down Expand Up @@ -91,27 +89,26 @@ def read
raise ::Redis::ProtocolError.new(err.message)
end

private

def setup_connect_callbacks(conn, f)
conn.callback do
@connection = conn
@state = :connected
f.resume conn
end
private

conn.errback do
@connection = conn
f.resume :refused
end
def setup_connect_callbacks(conn, f)
conn.callback do
@connection = conn
@state = :connected
f.resume conn
end

r = Fiber.yield
raise Errno::ECONNREFUSED if r == :refused
r
conn.errback do
@connection = conn
f.resume :refused
end

r = Fiber.yield
raise Errno::ECONNREFUSED if r == :refused
r
end
end
end
end

Redis::Connection.drivers << Redis::Connection::Synchrony
Redis::Connection.drivers << Redis::Connection::Synchrony

0 comments on commit 8a4af8b

Please sign in to comment.