class T1000::TransactionList

Public Class Methods

for_ip(ip, timeout: 3600) click to toggle source
# File lib/t-1000/transaction_list.rb, line 10
def self.for_ip(ip, timeout: 3600)
  new(ip, timeout: timeout)
end
new(ip, timeout: 3600) click to toggle source
# File lib/t-1000/transaction_list.rb, line 14
def initialize(ip, timeout: 3600)
  @timeout = timeout
  @key     = ActiveSupport::Cache.expand_cache_key [ip], :ip_request_tracker
  value    = T1000.cache.store.read(@key)
  replace Marshal.load value if value
  observe.added do
    T1000.cache.store.write @key, Marshal.dump(dup), expires_in: @timeout
  end
rescue Exception => e
  T1000.cache.store.delete @key
  raise e
end

Public Instance Methods

with_error() click to toggle source
# File lib/t-1000/transaction_list.rb, line 31
def with_error
  dup.replace select { |t| t.response.status >= 400 }
end
within(time) click to toggle source
# File lib/t-1000/transaction_list.rb, line 27
def within(time)
  dup.replace select { |t| t.time > time.ago }
end