Class: Blitz::Curl::Sprint
- Inherits:
-
Object
- Object
- Blitz::Curl::Sprint
- Defined in:
- lib/blitz/curl/sprint.rb
Overview
Use this to run a sprint against your app. The return values include the response time, the region from which the sprint was run along with the full request and response headers and the response body.
Defined Under Namespace
Classes: Request, Response, Result, Step
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
:nodoc:.
-
#job_id ⇒ Object
readonly
:nodoc:.
-
#region ⇒ Object
readonly
:nodoc:.
Instance Method Summary collapse
-
#abort ⇒ Object
:nodoc:.
-
#execute ⇒ Object
The primary method to execute a sprint from region.
-
#initialize(args) ⇒ Sprint
constructor
:nodoc:.
-
#queue ⇒ Object
:nodoc:.
-
#result ⇒ Object
:nodoc:.
Constructor Details
#initialize(args) ⇒ Sprint
:nodoc:
127 128 129 |
# File 'lib/blitz/curl/sprint.rb', line 127 def initialize args # :nodoc: @args = args end |
Instance Attribute Details
#args ⇒ Object (readonly)
:nodoc:
125 126 127 |
# File 'lib/blitz/curl/sprint.rb', line 125 def args @args end |
#job_id ⇒ Object (readonly)
:nodoc:
123 124 125 |
# File 'lib/blitz/curl/sprint.rb', line 123 def job_id @job_id end |
#region ⇒ Object (readonly)
:nodoc:
124 125 126 |
# File 'lib/blitz/curl/sprint.rb', line 124 def region @region end |
Instance Method Details
#abort ⇒ Object
:nodoc:
167 168 169 |
# File 'lib/blitz/curl/sprint.rb', line 167 def abort # :nodoc: Command::API.client.abort_job job_id rescue nil end |
#execute ⇒ Object
108 109 110 111 |
# File 'lib/blitz/curl/sprint.rb', line 108 def execute queue result end |
#queue ⇒ Object
:nodoc:
113 114 115 116 117 118 119 120 121 |
# File 'lib/blitz/curl/sprint.rb', line 113 def queue # :nodoc: args.delete 'pattern' args.delete :pattern res = Command::API.client.curl_execute args raise Error.new(res) if res['error'] @job_id = res['job_id'] @region = res['region'] end |
#result ⇒ Object
:nodoc:
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/blitz/curl/sprint.rb', line 131 def result # :nodoc: while true sleep 2.0 job = Command::API.client.job_status job_id if job['error'] raise Error end result = job['result'] next if job['status'] == 'queued' next if job['status'] == 'running' and not result raise Error if not result error = result['error'] if error if error == 'dns' raise Error::DNS.new(result) elsif error == 'connect' raise Error::Connect.new(result) elsif error == 'timeout' raise Error::Timeout.new(result) elsif error == 'parse' raise Error::Parse.new(result) elsif error == 'assert' raise Error::Status.new(result) else raise Error end end return Result.new(job) end end |