Commit 34b78acb authored by Kacper Bielecki's avatar Kacper Bielecki Committed by Paul Asmuth
Browse files

Events are added to Redis in reactor thread by inbound stream.

Before InboundStream#next_event method, which is not thread safe, was delegated to thread pool. However, InboundStream#push_next_event would delegate the execution back to reactor. In the end all redis blocking calls (we use rb-redis there) would be called from reactor.
parent ea6d5d43
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -7,7 +7,6 @@ class FnordMetric::API
  end
  
  def connect
    @redis = @@opts[:redis] if @@opts[:redis]
    @redis = Redis.connect(:url => @@opts[:redis_url])
  end
  
+2 −2
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@ class FnordMetric::InboundStream < EventMachine::Connection

  def receive_data(chunk)     
    @buffer << chunk         
    EM.defer{ next_event }
    next_event
  end

  def next_event