Class: Specwrk::Web::Endpoints::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/specwrk/web/endpoints/base.rb

Direct Known Subclasses

Health, Heartbeat, Popable, Report, Seed, Shutdown

Constant Summary collapse

MUTEX =
Mutex.new

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request) ⇒ Base

Returns a new instance of Base.



15
16
17
# File 'lib/specwrk/web/endpoints/base.rb', line 15

def initialize(request)
  @request = request
end

Instance Attribute Details

#started_atObject (readonly)

Returns the value of attribute started_at.



13
14
15
# File 'lib/specwrk/web/endpoints/base.rb', line 13

def started_at
  @started_at
end

Instance Method Details

#responseObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/specwrk/web/endpoints/base.rb', line 19

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
end

#with_responseObject



35
36
37
# File 'lib/specwrk/web/endpoints/base.rb', line 35

def with_response
  not_found
end