Class: Marathon::HealthCheck

Inherits:
Base
  • Object
show all
Defined in:
lib/marathon/health_check.rb

Overview

This class represents a Marathon HealthCheck. See mesosphere.github.io/marathon/docs/health-checks.html for full details.

Constant Summary collapse

DEFAULTS =
{
    :gracePeriodSeconds => 300,
    :intervalSeconds => 60,
    :maxConsecutiveFailures => 3,
    :path => '/',
    :portIndex => 0,
    :protocol => 'HTTP',
    :timeoutSeconds => 20
}
ACCESSORS =
%w[ command gracePeriodSeconds intervalSeconds maxConsecutiveFailures
path portIndex protocol timeoutSeconds ]

Instance Attribute Summary

Attributes inherited from Base

#info

Instance Method Summary collapse

Methods inherited from Base

#to_json

Methods included from Error

error_class, error_message, from_response

Constructor Details

#initialize(hash) ⇒ HealthCheck

Create a new health check object. hash: Hash returned by API.



20
21
22
23
# File 'lib/marathon/health_check.rb', line 20

def initialize(hash)
  super(Marathon::Util.merge_keywordized_hash(DEFAULTS, hash), ACCESSORS)
  Marathon::Util.validate_choice(:protocol, protocol, %w[HTTP TCP COMMAND])
end

Instance Method Details

#to_sObject



25
26
27
28
29
30
31
32
33
# File 'lib/marathon/health_check.rb', line 25

def to_s
  if protocol == 'COMMAND'
    "Marathon::HealthCheck { :protocol => #{protocol} :command => #{command} }"
  elsif protocol == 'HTTP'
    "Marathon::HealthCheck { :protocol => #{protocol} :portIndex => #{portIndex} :path => #{path} }"
  else
    "Marathon::HealthCheck { :protocol => #{protocol} :portIndex => #{portIndex} }"
  end
end