Class: Rets::MeasuringHttpClient

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

Instance Method Summary collapse

Constructor Details

#initialize(http_client, stats, prefix) ⇒ MeasuringHttpClient

Returns a new instance of MeasuringHttpClient.



3
4
5
6
7
# File 'lib/rets/measuring_http_client.rb', line 3

def initialize(http_client, stats, prefix)
  @http_client = http_client
  @stats = stats
  @prefix = prefix
end

Instance Method Details

#http_get(url, params = nil, extra_headers = {}) ⇒ Object



9
10
11
12
13
14
# File 'lib/rets/measuring_http_client.rb', line 9

def http_get(url, params=nil, extra_headers={})
  @stats.count("#{@prefix}.http_get_rate")
  @stats.time("#{@prefix}.http_get") do
    @http_client.http_get(url, params, extra_headers)
  end
end

#http_post(url, params, extra_headers = {}) ⇒ Object



16
17
18
19
20
21
# File 'lib/rets/measuring_http_client.rb', line 16

def http_post(url, params, extra_headers = {})
  @stats.count("#{@prefix}.http_post_rate")
  @stats.time("#{@prefix}.http_post") do
    @http_client.http_post(url, params, extra_headers)
  end
end


23
24
25
# File 'lib/rets/measuring_http_client.rb', line 23

def save_cookie_store(force=nil)
  @http_client.save_cookie_store(force)
end