Class: Specwrk::Web::Endpoints::Base
- Inherits:
-
Object
- Object
- Specwrk::Web::Endpoints::Base
- Defined in:
- lib/specwrk/web/endpoints/base.rb
Constant Summary collapse
- MUTEX =
Mutex.new
- InvalidGzipError =
Class.new(StandardError)
- UnsupportedContentEncodingError =
Class.new(StandardError)
Instance Attribute Summary collapse
-
#started_at ⇒ Object
readonly
Returns the value of attribute started_at.
Instance Method Summary collapse
-
#initialize(request) ⇒ Base
constructor
A new instance of Base.
- #response ⇒ Object
- #with_response ⇒ Object
Constructor Details
#initialize(request) ⇒ Base
Returns a new instance of Base.
18 19 20 |
# File 'lib/specwrk/web/endpoints/base.rb', line 18 def initialize(request) @request = request end |
Instance Attribute Details
#started_at ⇒ Object (readonly)
Returns the value of attribute started_at.
16 17 18 |
# File 'lib/specwrk/web/endpoints/base.rb', line 16 def started_at @started_at end |
Instance Method Details
#response ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/specwrk/web/endpoints/base.rb', line 22 def response return with_response unless run_id # No run_id, no datastore usage in the endpoint payload # parse the payload before any locking worker.first_seen_at ||= Time.now worker.last_seen_at = Time.now started_at = [:started_at] ||= Time.now.iso8601 @started_at = Time.parse(started_at) with_response.tap do |response| response[1]["x-specwrk-status"] = worker_status.to_s end rescue Store::LockUnavailableError locked rescue InvalidGzipError [400, {"content-type" => "text/plain"}, ["Invalid gzip request body"]] rescue UnsupportedContentEncodingError [415, {"content-type" => "text/plain"}, ["Unsupported content encoding"]] end |
#with_response ⇒ Object
44 45 46 |
# File 'lib/specwrk/web/endpoints/base.rb', line 44 def with_response not_found end |