Class: Bamboo::CachingService

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet_x/bamboo/server.rb

Overview

Ensures the referenced Bamboo instance is up and running. It does the health check only once and caches the result.

Instance Method Summary collapse

Constructor Details

#initialize(delegatee) ⇒ CachingService

delegatee - the actual Bamboo::Service to be used to do the health checking



11
12
13
# File 'lib/puppet_x/bamboo/server.rb', line 11

def initialize(delegatee)
  @delegatee = delegatee
end

Instance Method Details

#ensure_runningObject

See Bamboo::Service.ensure_running.



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/puppet_x/bamboo/server.rb', line 17

def ensure_running
  if @last_result == :not_running
    fail("Bamboo service failed a previous health check.")
  else
    begin
      @delegatee.ensure_running
      @last_result = :running
    rescue => e
      @last_result = :not_running
      raise e
    end
  end
end