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
34
35
36
37
38
39
40
41
# 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

  before_lock

  worker.first_seen_at ||= Time.now
  worker.last_seen_at = Time.now

  final_response = with_lock do
    started_at = [:started_at] ||= Time.now.iso8601
    @started_at = Time.parse(started_at)

    with_response
  end

  after_lock

  final_response[1]["x-specwrk-status"] = worker_status.to_s

  final_response
end

#with_responseObject



43
44
45
# File 'lib/specwrk/web/endpoints/base.rb', line 43

def with_response
  not_found
end