Class: Benchy::Worker
- Inherits:
-
Object
- Object
- Benchy::Worker
- Defined in:
- lib/benchy.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#request ⇒ Object
Returns the value of attribute request.
Instance Method Summary collapse
- #halt ⇒ Object
- #halted? ⇒ Boolean
-
#initialize(request, name) ⇒ Worker
constructor
A new instance of Worker.
-
#run ⇒ Object
Run, and keep running!.
Constructor Details
#initialize(request, name) ⇒ Worker
Returns a new instance of Worker.
33 34 35 |
# File 'lib/benchy.rb', line 33 def initialize(request, name) @request, @name = request, name end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
31 32 33 |
# File 'lib/benchy.rb', line 31 def name @name end |
#request ⇒ Object
Returns the value of attribute request.
31 32 33 |
# File 'lib/benchy.rb', line 31 def request @request end |
Instance Method Details
#halt ⇒ Object
52 53 54 |
# File 'lib/benchy.rb', line 52 def halt @halted = false end |
#halted? ⇒ Boolean
56 57 58 |
# File 'lib/benchy.rb', line 56 def halted? !!@halted end |
#run ⇒ Object
Run, and keep running!
38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/benchy.rb', line 38 def run return if halted? http = request.em http.callback { Benchy.logger.info "#{name}\t| #{request.method.upcase} #{request.url} - HTTP #{http.response_header.status}" run } http.errback { Benchy.logger.error "#{name}\t| Connection error!" halt # TODO - Make this fail the ping and try again, not halt } end |