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.



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

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

Instance Method Details

#closeObject



66
67
68
69
70
71
72
73
# File 'lib/appsignal/rack/streaming_listener.rb', line 66

def close
  @stream.close if @stream.respond_to?(:close)
rescue Exception => e # rubocop:disable Lint/RescueException
  @transaction.set_error(e)
  raise e
ensure
  Appsignal::Transaction.complete_current!
end

#eachObject



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

def each
  @stream.each { |c| yield(c) }
rescue Exception => e # rubocop:disable Lint/RescueException
  @transaction.set_error(e)
  raise e
end