Class: Drnbench::HttpClient
- Inherits:
-
Object
- Object
- Drnbench::HttpClient
- Defined in:
- lib/drnbench/client/http.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#requests ⇒ Object
readonly
Returns the value of attribute requests.
-
#results ⇒ Object
readonly
Returns the value of attribute results.
-
#wait ⇒ Object
readonly
Returns the value of attribute wait.
Instance Method Summary collapse
-
#initialize(params, config) ⇒ HttpClient
constructor
A new instance of HttpClient.
- #run ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(params, config) ⇒ HttpClient
Returns a new instance of HttpClient.
24 25 26 27 28 |
# File 'lib/drnbench/client/http.rb', line 24 def initialize(params, config) @requests = params[:requests] @result = params[:result] @config = config end |
Instance Attribute Details
#requests ⇒ Object (readonly)
Returns the value of attribute requests.
22 23 24 |
# File 'lib/drnbench/client/http.rb', line 22 def requests @requests end |
#results ⇒ Object (readonly)
Returns the value of attribute results.
22 23 24 |
# File 'lib/drnbench/client/http.rb', line 22 def results @results end |
#wait ⇒ Object (readonly)
Returns the value of attribute wait.
22 23 24 |
# File 'lib/drnbench/client/http.rb', line 22 def wait @wait end |
Instance Method Details
#run ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/drnbench/client/http.rb', line 30 def run @thread = Thread.new do loop do request = @requests.pop request = fixup_request(request) client = Droonga::Client.new(:protocol => :http, :host => request["host"], :port => request["port"]) request["headers"] ||= {} request["headers"]["user-agent"] = "Ruby/#{RUBY_VERSION} Droonga::Benchmark::Runner::HttpClient" start_time = Time.now response = client.request(request) @result << { :request => request, :status => response.code, :elapsed_time => Time.now - start_time, } sleep @config.wait end end self end |
#stop ⇒ Object
54 55 56 |
# File 'lib/drnbench/client/http.rb', line 54 def stop @thread.exit end |