Skip to content

Commit

Permalink
support for async processing within the on_data callback
Browse files Browse the repository at this point in the history
  • Loading branch information
igrigorik committed Feb 21, 2010
1 parent 35f658c commit 08bc0db
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/em-proxy/connection.rb
Expand Up @@ -19,6 +19,11 @@ def receive_data(data)
debug [:connection, data]
processed = @on_data.call(data)

return if processed == :async or processed.nil?
relay_to_servers(processed)
end

def relay_to_servers(processed)
if processed.is_a? Array
data, servers = *processed

Expand All @@ -33,7 +38,7 @@ def receive_data(data)
s.send_data data unless data.nil?
end
end

#
# initialize connections to backend servers
#
Expand Down

0 comments on commit 08bc0db

Please sign in to comment.