Class: Appsignal::StreamWrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/appsignal/rack/streaming_listener.rb

Instance Method Summary collapse

Constructor Details

#initialize(stream, transaction) ⇒ StreamWrapper

Returns a new instance of StreamWrapper.


49
50
51
52
# File 'lib/appsignal/rack/streaming_listener.rb', line 49

def initialize(stream, transaction)
   @stream      = stream
   @transaction = transaction
end

Instance Method Details

#closeObject


60
61
62
63
64
65
66
# File 'lib/appsignal/rack/streaming_listener.rb', line 60

def close
  @stream.close if @stream.respond_to?(:close)
rescue Exception => e
  @transaction.set_error(e); raise e
ensure
  Appsignal::Transaction.complete_current!
end

#eachObject


54
55
56
57
58
# File 'lib/appsignal/rack/streaming_listener.rb', line 54

def each
  @stream.each { |c| yield(c) }
rescue Exception => e
  @transaction.set_error(e); raise e
end