Class: Webmeter::Worker
- Inherits:
-
Object
- Object
- Webmeter::Worker
- Defined in:
- lib/webmeter/worker.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
Returns the value of attribute host.
-
#paths ⇒ Object
Returns the value of attribute paths.
-
#user_agent ⇒ Object
Returns the value of attribute user_agent.
Instance Method Summary collapse
-
#initialize(host, paths) ⇒ Worker
constructor
A new instance of Worker.
- #run ⇒ Object
- #work ⇒ Object
Constructor Details
#initialize(host, paths) ⇒ Worker
Returns a new instance of Worker.
7 8 9 10 |
# File 'lib/webmeter/worker.rb', line 7 def initialize(host, paths) @host = host @paths = paths end |
Instance Attribute Details
#host ⇒ Object
Returns the value of attribute host.
5 6 7 |
# File 'lib/webmeter/worker.rb', line 5 def host @host end |
#paths ⇒ Object
Returns the value of attribute paths.
5 6 7 |
# File 'lib/webmeter/worker.rb', line 5 def paths @paths end |
#user_agent ⇒ Object
Returns the value of attribute user_agent.
5 6 7 |
# File 'lib/webmeter/worker.rb', line 5 def user_agent @user_agent end |
Instance Method Details
#run ⇒ Object
20 21 22 |
# File 'lib/webmeter/worker.rb', line 20 def run Thread.new { work } end |
#work ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/webmeter/worker.rb', line 12 def work @paths.each { |path| req = Net::HTTP::Get.new(path, {'User-Agent' => "Webmeter/worker-#{@user_agent}"}) req.basic_auth('user', 'password') res = Net::HTTP.new(@host).start { |http| http.request(req) } } end |