Class: PostgreSQLAccumulator

Inherits:
Object
  • Object
show all
Defined in:
lib/pqa.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePostgreSQLAccumulator

Returns a new instance of PostgreSQLAccumulator.



643
644
645
646
647
648
649
# File 'lib/pqa.rb', line 643

def initialize
  @queries = []
  @errors = []
  @working = {}
  @stream = LogStream.new
  @has_duration_info = false
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



641
642
643
# File 'lib/pqa.rb', line 641

def errors
  @errors
end

#has_duration_infoObject (readonly)

Returns the value of attribute has_duration_info.



641
642
643
# File 'lib/pqa.rb', line 641

def has_duration_info
  @has_duration_info
end

#queriesObject (readonly)

Returns the value of attribute queries.



641
642
643
# File 'lib/pqa.rb', line 641

def queries
  @queries
end

Instance Method Details

#append(line) ⇒ Object



651
652
653
654
655
656
657
658
659
660
661
662
663
664
# File 'lib/pqa.rb', line 651

def append(line)
  if line.connection_id
    if !@working.has_key?(line.connection_id)
      @working[line.connection_id] = LogStream.new
    end
    query = @working[line.connection_id].append(line)
  else
    # no pid mode :
    query = @stream.append(line)
  end
  if query && !query.ignored
    query.accumulate_to(self)
  end
end

#append_error(error) ⇒ Object



670
671
672
# File 'lib/pqa.rb', line 670

def append_error(error)
  @errors.push(error)
end

#append_query(query) ⇒ Object



666
667
668
# File 'lib/pqa.rb', line 666

def append_query(query)
  @queries.push(query)
end

#close_out_allObject



674
675
676
677
678
679
680
681
# File 'lib/pqa.rb', line 674

def close_out_all 
  @stream.queries.each { |q| q.accumulate_to(self) }
  @has_duration_info = @stream.has_duration_info
  @working.each {|k, stream|
    stream.queries.each { |q| q.accumulate_to(self) }
    @has_duration_info = @has_duration_info || stream.has_duration_info
  }
end